Need help Converting code to C from C+

# include
# include

using namespace std;

int main()
{
double amount,tax, sale;
int choice;
for(;;)
{
cout<<"Please input the purchase amount :"<<endl;
cin>>amount;
if(amount>=0)
break;
else
cout<<"Invalid value"<<endl;
}
for(;;)
{
cout<<"Please select which store to use for the tax calculation "<<endl;
cout<<"1- Del Mar "<<endl<<"2- Encinitas"<<endl<<"3- La Jolla "<<endl;
cin>>choice;
if(choice>3||choice<1)
cout<<"Invalid value"<<endl;
else
break;
}
switch(choice)
{
case 1:
tax=0.0725;
break;
case 2:
tax=0.075;
break;
case 3:
tax=0.0775;
break;
}
tax=tax*amount;
sale=amount+tax;
cout<<"Amount Store Tax Total sale"<<endl;
cout<<fixed<<setprecision(2);
cout<<amount<<" ";
switch(choice)
{
case 1:
cout<<"Del Mar ";
break;
case 2:
cout<<"Encinitas";
break;
case 3:
cout<<"La Jolla ";
break;
}
cout<<" "<<tax<<" "<<sale<<endl;
return 0;
}
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion