I have to create a program that takes input from a user and calculates the cost, with a do-while loop. The program asks what the price is, what the discount is and what the tax is. The program does that but the calculation is wrong and the loop doesn't work. I'm not sure what has to be changed.
int main()
{
do {
cout<<"What is the original price?";
cin>>original_cost;
cout.setf (ios::fixed);
cout.setf (ios::showpoint);
cout.precision(2);
cout<<"What is the discount?";
cin>>discount;
cout.setf (ios::fixed);
cout.setf (ios::showpoint);
cout.precision(2);
cout<<"What is the tax?";
cin>>tax;
cout.setf (ios::fixed);
cout.setf (ios::showpoint);
cout.precision(2);
cout<<"The total is"<<original_cost*discount+original_cost*tax-discount;
cout<<"Do you want to try again?";
cin>>answer;
} while(answer=='Y'||'y');
return 0;
}
Comments
Leave a comment