Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Cis215 ch4 programming assignment
- #include <iostream>
- #include <string>
- #include <iomanip>
- #include <cstdlib>
- #include <stdlib.h>
- #include <fstream>
- using namespace std;
- int main()
- {
- string server;
- double ricky;
- double newbill = 0;
- int pick = 5;
- int items;
- int test = 0;
- int choice, total = 0;
- int dow;
- int bonus;
- int flag = 0;
- double numMeals;
- double bill = 0.0;
- double newtax = 0;
- double tip;
- double tip_precentage, newtip;
- double tax = 0.09;
- double totalbill;
- double totaldue;
- double newtotal;
- const string inn = "The Green Dragon Inn";
- const double rate = 0.09;
- do {
- // choices
- cout << endl;
- cout << "Main Menu\n";
- cout << "1) Food Menu\n";
- cout << "2) Calculate Bill\n";
- cout << "3) Exit\n";
- cout << "Please enter your choice (1- 3):\n";
- cin >> choice;
- while (pick >= 5 )
- {
- switch (choice)
- {
- case 1:
- cout << endl;
- cout << "Slice of Pizza 1.99\n";
- cout << "Bacon Burger 5.99\n";
- cout << "Chicken Tenders 7.99 \n";
- cout << "Rack of Ribs 12.99\n";
- cout << "Chicken Salad 3.99\n";
- cout << "Fries 2.99\n";
- cout << "BBQ Sandwich 4.99\n";
- cout << "Loaded Baked Potato 6.99\n";
- cout << endl;
- cout << "please pick day of the week\n" << endl;
- cout << "1) Monday\n";
- cout << "2) Tuesday\n";
- cout << "3) Wednesday\n";
- cout << "4) Thursday\n";
- cout << "5) Friday\n";
- cout << "6) Saturday\n";
- cout << "7) Sunday\n";
- cin >> dow;
- if (dow == 1)
- {
- cout << "Special for Monday - free fries with a BBQ Sandwich" << endl;
- cout << endl;
- }
- else if (dow == 2) {
- cout << "Special for Tuesday is $1.00 off a rack of ribs\n";
- cout << endl;
- }
- else if (dow == 3) {
- cout << "Special for Wednesday is $1.00 off loaded baked potato\n";
- cout << endl;
- }
- else if (dow == 4) {
- cout << "Special for Thursday is $1.00 off chicken tenders\n";
- cout << endl;
- }
- else if (dow == 5) {
- cout << "Special for Friday is TGIF free slice of pizza with every order\n";
- cout << endl;
- }
- else if (dow == 6) {
- cout << "No Special for today but thanks for dining with us!\n";
- cout << endl;
- }
- else if (dow == 7) {
- cout << "No Special for today but thanks for dining with us!\n";
- cout << endl;
- }
- break;
- case 2:
- cin.ignore();
- cout << "servers name:" << endl;
- getline(cin, server);
- // enter bill and tip
- cout << " how many meals did you order\n";
- cin >> items;
- for (int count = 1; count <= items; count++)
- {
- double sales;
- cout << "enter sales" << count << ": ";
- cin >> sales;
- bill += sales;
- }
- cout << fixed << showpoint << setprecision(2);
- cout << "total sales is $" << total << endl;
- cout << "Please select a tip amount\n";
- cout << endl;
- cout << "1) 20%\n";
- cout << "2) 18%\n";
- cout << "3) 15%\n";
- cout << "4) 12%\n";
- cout << "5) 10%\n";
- cout << "6) other\n";
- cin >> test;
- break;
- case 3:
- cout << "good bye!\n";
- break;
- default: cout << "not a vaild choice restart program and try again.\n";
- cout << endl;
- }
- // switch statement
- switch (test)
- {
- case 1:
- tip_precentage = 20;
- cout << "_____________________________";
- cout << "You entered the following:\n";
- cout << "Bill Amount:" << setw(19) << "$" << bill << endl;
- cout << "Tip:" << setw(28) << static_cast<int>(0.20 * 100) << "%" << endl;
- cout << "Tax rate is:" << setw(20) << static_cast<int> (0.09 * 100) << "%" << endl;
- tax = bill * rate;
- tip = (bill + tax) / 100 * 20;
- totalbill = tax + bill + tip;
- cout << setprecision(2) << fixed;
- cout << "_______________________________" << endl;
- ricky = (bill * 0.05);
- newbill = bill - ricky;
- newtax = newbill * rate;
- newtip = (newbill + newtax) * .20;
- newtotal = newbill + newtax + newtip;
- if (bill > 40.00 && tip_precentage > 12.00)
- {
- cout << "you have a 5% discount\n";
- cout << "tax" << setw(28) << "$" << newtax << endl;
- cout << "tip" << setw(28) << "$" << newtip << endl;
- cout << endl;
- cout << "your new bill amount:" << setw(10) << "$" << newbill << endl;
- cout << "____________________________\n";
- cout << "Total due:" << setw(21) << "$" << newtotal << endl;
- cout << endl;
- cout << "Thanks for dining with us at" << " " << inn;
- cout << endl;
- cout << endl;
- srand(time(NULL));
- cout << "Your table number is " << rand() % 20 << endl;
- cout << endl;
- cout << "You were served by:" << " " << server << endl;
- cout << endl;
- cout << "Thanks for dining with us!" << endl;
- cout << endl;
- char letter;
- cin.ignore();
- cout << "Press Enter to continue";
- cin.get(letter);
- }
- else
- {
- cout << "tax" << setw(28) << "$" << tax << endl;
- cout << "tip" << setw(28) << "$" << tip << endl;
- cout << "Total Bill:" << setw(20) << "$" << totalbill << endl;
- cout << endl;
- cout << "Thanks for dining with us at" << " " << inn;
- cout << endl;
- cout << endl;
- srand(time(NULL));
- cout << "Your table number is " << rand() % 20 << endl;
- cout << endl;
- cout << "You were served by:" << " " << server << endl;
- cout << endl;
- cout << "Thanks for dining with us!" << endl;
- cout << endl;
- char letter;
- cin.ignore();
- cout << "Press Enter to continue";
- cin.get(letter);
- break;
- }
- break;
- case 2:
- tip_precentage = 18;
- cout << "_____________________________";
- cout << "You entered the following:\n";
- cout << "Bill Amount:" << setw(19) << "$" << bill << endl;
- cout << "Tip:" << setw(28) << static_cast<int>(0.18 * 100) << "%" << endl;
- cout << "Tax rate is:" << setw(20) << static_cast<int> (0.09 * 100) << "%" << endl;
- tax = bill * rate;
- tip = (bill + tax) / 100 * 18;
- totalbill = tax + bill + tip;
- cout << setprecision(2) << fixed;
- cout << "_______________________________" << endl;
- ricky = (bill * 0.05);
- newbill = bill - ricky;
- newtax = newbill * rate;
- newtip = (newbill + newtax) * .18;
- newtotal = newbill + newtax + newtip;
- if (bill > 40.00 && tip_precentage > 12.00)
- {
- cout << "you have a 5% discount\n";
- cout << "tax" << setw(28) << "$" << newtax << endl;
- cout << "tip" << setw(28) << "$" << newtip << endl;
- cout << endl;
- cout << "your new bill amount:" << setw(10) << "$" << newbill << endl;
- cout << "____________________________\n";
- cout << "Total due:" << setw(21) << "$" << newtotal << endl;
- cout << endl;
- cout << "Thanks for dining with us at" << " " << inn;
- cout << endl;
- cout << endl;
- srand(time(NULL));
- cout << "Your table number is " << rand() % 20 << endl;
- cout << endl;
- cout << "You were served by:" << " " << server << endl;
- cout << endl;
- cout << "Thanks for dining with us!" << endl;
- cout << endl;
- char letter;
- cin.ignore();
- cout << "Press Enter to continue";
- cin.get(letter);
- }
- else
- {
- cout << "Total Bill:" << setw(20) << "$" << totalbill << endl;
- cout << "tax" << setw(28) << "$" << tax << endl;
- cout << "tip" << setw(28) << "$" << tip << endl;
- cout << endl;
- cout << "Thanks for dining with us at" << " " << inn;
- cout << endl;
- cout << endl;
- srand(time(NULL));
- cout << "Your table number is " << rand() % 20 << endl;
- cout << endl;
- cout << "You were served by:" << " " << server << endl;
- cout << endl;
- cout << "Thanks for dining with us!" << endl;
- cout << endl;
- char letter;
- cin.ignore();
- cout << "Press Enter to continue";
- cin.get(letter);
- break;
- }
- case 3:
- tip_precentage = 15;
- cout << "_____________________________";
- cout << "You entered the following:\n";
- cout << "Bill Amount:" << setw(19) << "$" << bill << endl;
- cout << "Tip:" << setw(28) << static_cast<int>(0.15 * 100) << "%" << endl;
- cout << "Tax rate is:" << setw(20) << static_cast<int> (0.09 * 100) << "%" << endl;
- tax = bill * rate;
- tip = (bill + tax) / 100 * 15;
- totalbill = tax + bill + tip;
- cout << setprecision(2) << fixed;
- cout << "_______________________________" << endl;
- ricky = (bill * 0.05);
- newbill = bill - ricky;
- newtax = newbill * rate;
- newtip = (newbill + newtax) * .15;
- newtotal = newbill + newtax + newtip;
- if (bill > 40.00 && tip_precentage > 12.00)
- {
- cout << "you have a 5% discount\n";
- cout << "tax" << setw(28) << "$" << newtax << endl;
- cout << "tip" << setw(28) << "$" << newtip << endl;
- cout << endl;
- cout << "your new bill amount:" << setw(10) << "$" << newbill << endl;
- cout << "____________________________\n";
- cout << "Total due:" << setw(21) << "$" << newtotal << endl;
- cout << endl;
- cout << "Thanks for dining with us at" << " " << inn;
- cout << endl;
- cout << endl;
- srand(time(NULL));
- cout << "Your table number is " << rand() % 20 << endl;
- cout << endl;
- cout << "You were served by:" << " " << server << endl;
- cout << endl;
- cout << "Thanks for dining with us!" << endl;
- cout << endl;
- char letter;
- cin.ignore();
- cout << "Press Enter to continue";
- cin.get(letter);
- }
- else
- {
- cout << "Total Bill:" << setw(20) << "$" << totalbill << endl;
- cout << "tax" << setw(28) << "$" << tax << endl;
- cout << "tip" << setw(28) << "$" << tip << endl;
- cout << endl;
- cout << "Thanks for dining with us at" << " " << inn;
- cout << endl;
- cout << endl;
- srand(time(NULL));
- cout << "Your table number is " << rand() % 20 << endl;
- cout << endl;
- cout << "You were served by:" << " " << server << endl;
- cout << endl;
- cout << "Thanks for dining with us!" << endl;
- cout << endl;
- char letter;
- cin.ignore();
- cout << "Press Enter to continue";
- cin.get(letter);
- break;
- }
- case 4:
- tip_precentage = 12;
- cout << "_____________________________";
- cout << "You entered the following:\n";
- cout << "Bill Amount:" << setw(19) << "$" << bill << endl;
- cout << "Tip:" << setw(28) << static_cast<int>(0.12 * 100) << "%" << endl;
- cout << "Tax rate is:" << setw(20) << static_cast<int> (0.09 * 100) << "%" << endl;
- tax = bill * rate;
- tip = (bill + tax) / 100 * 12;
- totalbill = tax + bill + tip;
- cout << setprecision(2) << fixed;
- cout << "_______________________________" << endl;
- ricky = (bill * 0.05);
- newbill = bill - ricky;
- newtax = newbill * rate;
- newtip = (newbill + newtax) * .12;
- newtotal = newbill + newtax + newtip;
- if (bill > 40.00 && tip_precentage > 12.00)
- {
- cout << "you have a 5% discount\n";
- cout << "tax" << setw(28) << "$" << newtax << endl;
- cout << "tip" << setw(28) << "$" << newtip << endl;
- cout << endl;
- cout << "your new bill amount:" << setw(10) << "$" << newbill << endl;
- cout << "____________________________\n";
- cout << "Total due:" << setw(21) << "$" << newtotal << endl;
- cout << endl;
- cout << "Thanks for dining with us at" << " " << inn;
- cout << endl;
- cout << endl;
- srand(time(NULL));
- cout << "Your table number is " << rand() % 20 << endl;
- cout << endl;
- cout << "You were served by:" << " " << server << endl;
- cout << endl;
- cout << "Thanks for dining with us!" << endl;
- cout << endl;
- char letter;
- cin.ignore();
- cout << "Press Enter to continue";
- cin.get(letter);;
- }
- else
- {
- cout << "Total Bill:" << setw(20) << "$" << totalbill << endl;
- cout << "tax" << setw(28) << "$" << tax << endl;
- cout << "tip" << setw(28) << "$" << tip << endl;
- cout << endl;
- cout << "Thanks for dining with us at" << " " << inn;
- cout << endl;
- cout << endl;
- srand(time(NULL));
- cout << "Your table number is " << rand() % 20 << endl;
- cout << endl;
- cout << "You were served by:" << " " << server << endl;
- cout << endl;
- cout << "Thanks for dining with us!" << endl;
- cout << endl;
- char letter;
- cin.ignore();
- cout << "Press Enter to continue";
- cin.get(letter);
- break;
- }
- case 5:
- tip_precentage = 10;
- cout << "_____________________________";
- cout << "You entered the following:\n";
- cout << "Bill Amount:" << setw(19) << "$" << bill << endl;
- cout << "Tip:" << setw(28) << static_cast<int>(0.10 * 100) << "%" << endl;
- cout << "Tax rate is:" << setw(20) << static_cast<int> (0.09 * 100) << "%" << endl;
- tax = bill * rate;
- tip = (bill + tax) / 100 * 10;
- totalbill = tax + bill + tip;
- cout << setprecision(2) << fixed;
- cout << "_______________________________" << endl;
- ricky = (bill * 0.05);
- newbill = bill - ricky;
- newtax = newbill * rate;
- newtip = (newbill + newtax) * .10;
- newtotal = newbill + newtax + newtip;
- if (bill > 40.00 && tip_precentage > 12.00)
- {
- cout << "you have a 5% discount\n";
- cout << "tax" << setw(28) << "$" << newtax << endl;
- cout << "tip" << setw(28) << "$" << newtip << endl;
- cout << endl;
- cout << "your new bill amount:" << setw(10) << "$" << newbill << endl;
- cout << "____________________________\n";
- cout << "Total due:" << setw(21) << "$" << newtotal << endl;
- cout << endl;
- cout << "Thanks for dining with us at" << " " << inn;
- cout << endl;
- cout << endl;
- srand(time(NULL));
- cout << "Your table number is " << rand() % 20 << endl;
- cout << endl;
- cout << "You were served by:" << " " << server << endl;
- cout << endl;
- cout << "Thanks for dining with us!" << endl;
- cout << endl;
- char letter;
- cin.ignore();
- cout << "Press Enter to continue";
- cin.get(letter);
- }
- else
- {
- cout << "Total Bill:" << setw(20) << "$" << totalbill << endl;
- cout << "tax" << setw(28) << "$" << tax << endl;
- cout << "tip" << setw(28) << "$" << tip << endl;
- cout << endl;
- cout << "Thanks for dining with us at" << " " << inn;
- cout << endl;
- cout << endl;
- srand(time(NULL));
- cout << "Your table number is " << rand() % 20 << endl;
- cout << endl;
- cout << "You were served by:" << " " << server << endl;
- cout << endl;
- cout << "Thanks for dining with us!" << endl;
- cout << endl;
- char letter;
- cin.ignore();
- cout << "Press Enter to continue";
- cin.get(letter);
- break;
- }
- case 6:
- cout << "Enter Tip precentage:%" << setw(10);
- cin >> tip_precentage;
- tax = static_cast<int>(tax * 100);
- cout << "Your Tax Rate Is:" << setw(10) << tax << "%" << endl;
- cout << setprecision(2) << fixed;
- cout << "Bill Amount:$" << setw(10) << bill << endl;
- tip_precentage = static_cast<int>(tip_precentage);
- cout << "Tip Percentage:" << setw(10) << tip_precentage;
- cout << endl;
- tax = bill * rate;
- cout << "Tax Amount:$" << setw(10) << tax << endl;
- tip = (tax + bill) / 100 * tip_precentage;
- cout << "Tip Amount:$" << setw(10) << tip << endl;
- cout << endl;
- totaldue = tax += tip += bill;
- cout << "Total Due:$" << setw(10) << totaldue << endl;
- cout << endl;
- cout << "Thanks for dining with us at\n" << inn;
- cout << endl;
- cout << endl;
- srand(time(NULL));
- cout << "Your table number is " << rand() % 20;
- cout << endl;
- cout << "You were served by:\n" << server << endl;
- cout << endl;
- cout << "Thanks for dining with us!" << endl;
- cout << endl;
- char letter;
- cin.ignore();
- cout << "Press Enter to continue";
- cin.get(letter);
- break;
- }
- cout << "do you want to see this again (Y or N)";
- cin >> pick;
- }
- }while (choice != 3);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement