How to put a counter..
Mar 9, 2014 at 1:01am UTC
So for this code I have a menu and I need to put counters for Falafel, Soda, and extras with their totals set to two decimal places. I already have a total and sub total for the order but not for individual items. please help.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char * argv[])
{
double total = 0.00;
double sub_total = 0.00;
double tax = 0.00;
double price;
char selection;
cout << "F = falafel 5.15" << endl;
cout << "S = soda 2.24" << endl;
cout << "X = extras 1.57" << endl;
cout << "T = total" << endl;
do
{
price = 0;
cout << "Make your selection (HSF): " ;
cin >> selection;
switch (selection)
{
case 'F' :
case 'f' :
price = 5.15;
break ;
case 'S' :
case 's' :
price = 2.24;
break ;
case 'X' :
case 'x' :
price = 1.57;
break ;
case 'T' :
case 't' :
break ;
default :
cout << "Illegal selection, try again." << endl;
}
total += price + (price* .087);
sub_total += price;
tax += (price* .087);
} while (selection != 'T' && selection != 't' );
cout << setiosflags(ios::fixed) << setiosflags(ios::showpoint);
cout << "The Subtotal is: $" << setprecision(2) << sub_total << endl;
cout << setiosflags(ios::fixed) << setiosflags(ios::showpoint);
cout << "The Tax is: $" << setprecision(2) << tax << endl;
cout << setiosflags(ios::fixed) << setiosflags(ios::showpoint);
cout << "The Total is: $" << setprecision(2) << total << endl;
return 0;
}
Topic archived. No new replies allowed.