Hello,
I have created a program for my class, were I am asked to get input of the number of chairs sold, and to output the total sales for all the chairs.
The program runs perfectly, but I can't get the first output to change from scientific notation to fixedpoint notation. (Yes, I an have the headerfile <iomanip> and I even used setprecision to 2 decimal places, and used fixed. Please help!
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
cout<<" How many American Colonial chairs were sold? " <<endl; //Get number of ACC chairs sold
cin>> ACC;
Total_ACC= ACC* 85.00; //calculate total sales for American Colonial chairs
cout<< "The Total sales of American Colonial chairs is " ;
cout<< setprecision(2)<<showpoint<<Total_ACC<<fixed<<" dollars"<<endl;
cout<< "How many Modern Chairs were sold?"<< endl; //Get number of MC chairs sold
cin>> MC;
Total_MC= MC* 57.50; //calculate total sales for Mordern Chairs
cout<< "The total sales of Modern chairs is ";
cout<<setprecision(2)<<showpoint<<Total_MC<<fixed<<" dollars"<<endl;
cout<< "How many French Classical Chairs were sold ? "<< endl; //Get number of FCC chairs sold
cin>> FCC;
Total_FCC= FCC* 127.75; //calculate total sales for French Classical chairs
cout<< "The total sales of French Classical chairs is " ;
cout<<setprecision(2)<<showpoint<<Total_FCC<<fixed<<" dollars"<<endl;
totalcostofallchairs= Total_ACC+Total_MC+Total_FCC; //Compute the total sale price for all chairs bought
cout<<"The total cost for all the chairs you bought is ";
cout<<setprecision(2)<<showpoint<<totalcostofallchairs<<fixed<< " dollars"<<endl;
Thank you so much for the clarification of having one setprecision()/showpoint/fixed in the program.
I have now placed the set precision()/showpoint/fixed in the first part of the program as below:
cout<< "The Total sales of American Colonial chairs is " ;
cout<< setprecision(2)<<showpoint<<Total_ACC<<fixed<<" dollars"<<endl;
but the answer always comes out in scientific notation for that specific one.
Any thoughts?
OH!
Got it.
Because my book had told me to insert it this way
cout<< setprecision(2)<<showpoint<<VARIABLE NAME<<fixed<<endl;
Thanks for the help!
Besides that, can anyone please tell me if I may have overlooked anything?
The program is running fine, but my teacher seems to be meticulous about the order of the program etc....