Answer to Question #30555 in C++ for Tom

Question #30555
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.

#include <iostream>
#include <cmath>

using namespace std;

double original_cost;
double discount;
double tax;
double total;
char answer;

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;
}
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS