-
May 15th, 2013, 10:46 PM
#1
C++ Program
I'm trying to create a program that will take input from a user and calculate it in a do-while loop. The program does the calculation but the answer is wrong. The loop also doesn't work. The purpose of the program is to see how much an item will cost after a discount is taken off and tax is added.
#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;
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|