Posted: 10/14/2009 3:12:54 PM EDT
|
Everything works now, I just have problems with the two outputs at the end of tax amount and total bill not being set to 2 decimal places
I thought I had rounding covered, but it doesnt work, any ideas? i know generically speaking its:
|
|
Quoted:
Make sure you have the '.' in front of '2lf'. It may not put a trailing zero on 5.5 though, can't remember, but you could code that in by checking the number of digits after the . point if need be. original output: Welcome Johnny's Restaurant 1 #3 Muffin.............. 0.99 Tax $0.0545 Amount Due $1.0445 here the 1 in front is how many i ordered cout << "Tax" << setw (27) << "$" << printf("%.2lf", tax) << endl; cout << "Amount Due" << setw (20) << "$" << printf("%.2lf", totalBill) << endl; screwed up my output: Welcome Johnny's Restaurant 1 #3 Muffin.............. 0.99 0.05Tax $4 1.04Amount Due $4 which are the right values on the left side for some reason? and lost the 1 ETA its tabbed correctly in the console, just lost it in copy and past |
|
Quoted: Quoted: Make sure you have the '.' in front of '2lf'. It may not put a trailing zero on 5.5 though, can't remember, but you could code that in by checking the number of digits after the . point if need be. original output: Welcome Johnny's Restaurant 1 #3 Muffin.............. 0.99 Tax $0.0545 Amount Due $1.0445 cout << "Tax" << setw (27) << "$" << printf("%.2lf", tax) << endl; cout << "Amount Due" << setw (20) << "$" << printf("%.2lf", totalBill) << endl; screwed up my output: Welcome Johnny's Restaurant 1 #3 Muffin.............. 0.99 0.05Tax $4 1.04Amount Due $4 which are the right values on the left side for some reason? ETA its tabbed correctly in the console, just lost it in copy and past looks like printf() is firing off first. There is a way to do it with cout and C++ syntax, but I am not familiar with C++. using printf() only it would be: printf("Tax $%.2lf\n", tax); printf("Amount Due $%.2lf\n", totalBill);
|
|
Quoted:
Quoted:
Quoted:
Make sure you have the '.' in front of '2lf'. It may not put a trailing zero on 5.5 though, can't remember, but you could code that in by checking the number of digits after the . point if need be. original output: Welcome Johnny's Restaurant 1 #3 Muffin.............. 0.99 Tax $0.0545 Amount Due $1.0445 cout << "Tax" << setw (27) << "$" << printf("%.2lf", tax) << endl; cout << "Amount Due" << setw (20) << "$" << printf("%.2lf", totalBill) << endl; screwed up my output: Welcome Johnny's Restaurant 1 #3 Muffin.............. 0.99 0.05Tax $4 1.04Amount Due $4 which are the right values on the left side for some reason? ETA its tabbed correctly in the console, just lost it in copy and past looks like printf() is firing off first. There is a way to do it with cout and C++ syntax, but I am not familiar with C++. using printf() only it would be: printf("Tax $%.2lf\n", tax); printf("Amount Due $%.2lf\n", totalBill); cout << printf("Tax $%.2lf\n", tax) << endl; cout << printf("Amount Due $%.2lf\n", totalBill) << endl; Welcome Johnny's Restaurant 1 #3 Muffin.............. 0.99 Tax $0.05 10 Amount Due $1.04 17 im just plugging and chugging right now, its close. Im trying to look up actual syntax |
.numOrdered to all 0's.