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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
#include <iostream>
#include <iomanip>
using namespace std;
void showMenu();
void showFees(double,double,double,double);
void showTotal(double,double, double);
int main(int argc, const char * argv[]) {
int choice;
double bill = 0 , taxes=.65, tips=.20;
double TotalBill = 0, AmountTender= 0, change = 0;
const int Hamburger = 1,
Hotdog = 2,
Peanuts = 3,
Popcorn = 4,
Soda = 5,
Chips = 6,
Water = 7,
EndOrder = 8;
cout<< fixed << showpoint << setprecision(2);
do {
showMenu();
cin>> choice;
while (choice < Hamburger || choice > EndOrder) {
cout<<"Please Enter Valid Choice";
cin>> choice;
}
while (choice != EndOrder) {
cout<< "Enter Menu Item: ";
cin>> choice;
if (choice == Hamburger)
{ bill = bill + 6.00;}
else if (choice == Hotdog){ bill = bill + 4.50;}
else if (choice == Peanuts){ bill = bill + 3.75;}
else if (choice == Popcorn){ bill = bill + 5.50;}
else if (choice == Soda){ bill = bill + 2.80;}
else if (choice == Chips){ bill = bill + 1.00;}
else if (choice == Water){ bill = bill + 2.00;}
else { bill = bill + 0;};
}
} while (choice != 8);
showFees(bill,taxes,tips,TotalBill);
showTotal(TotalBill, AmountTender, change);
cout << "End order \n";
return 0;
}
void showMenu(){
cout<< "\n \t \t Baseball Game Snack Menu \n \n";
cout<< "1 – Hamburger $6.00 \n";
cout<< "2 – Hotdog $4.50 \n";
cout<< "3 – Peanuts $3.75 \n";
cout<< "4 – Popcorn $5.50 \n";
cout<< "5 – Soda $2.80 \n";
cout<< "6 – Chips $1.00 \n";
cout<< "7 – Water $2.00 \n";
cout<< "8 – End order";
cout<<"\n\t";
cout<<"Enter Menu Item:";
};
void showFees(double bill, double Tax, double Tip, double TotalBill){
cout<<"Bill: $" <<bill <<"\n";
Tax = bill * .65;
cout<<"Tax: $"<< Tax <<"\n";
Tip = bill * .20;
cout<<"Tip: $" << Tip <<"\n";
TotalBill = bill + Tax + Tip;
cout<<"TotalBill: $" << TotalBill <<"\n";
};
void showTotal(double TotalBill, double AmountTender, double change){
while (TotalBill != 0) {
cout<<"Amount Tendered: $";
cin>> AmountTender;
while (AmountTender < TotalBill) {
cout<<"Amount paid is not enough to cover bill, please enter new amount: $";
cin>>AmountTender;
}
change = AmountTender - TotalBill;
cout<<"Change due: $"<<change <<"\n";
TotalBill = 0;
}
};
|