Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- using namespace std;
- struct menuItemType
- {
- string menuItem[10];
- float menuPrice[10];
- };
- //show data
- void showmenu();
- //get data
- void getData(menuItemType & mList, int & c);
- //print check
- void printCheck(menuItemType & mList, int & c);
- int main()
- {
- menuItemType menuList;
- int c;
- showmenu();
- getData(menuList, c);
- printCheck(menuList, c);
- }
- void showmenu()
- {
- cout << "Welcome to Johnny's Restaurant" << endl;
- cout << "\n1. Plain Egg" << "\t\t" << "$1.45" << endl;
- cout << "2. Bacon and Egg" << "\t" << "$2.45" << endl;
- cout << "3. Muffin" << "\t\t" << "$0.99" << endl;
- cout << "4. French Toast" << "\t\t" << "$1.99" << endl;
- cout << "5. Fruit Basket" << "\t\t" << "$2.49" << endl;
- cout << "6. Cereal" << "\t\t" << "$0.69" << endl;
- cout << "7. Coffee" << "\t\t" << "$0.50" << endl;
- cout << "8. Tea" << "\t\t\t" << "$0.75" << endl;
- }
- void getData(menuItemType & mList, int & c)
- {
- int choice;
- cout << "\nEnter the total number of items selected: ";
- cin >> c;
- cout << "\nEnter the items selected:" << endl;
- cout << setprecision(2) << fixed;
- for (int i = 0; i < c; i++)
- {
- cin >> choice;
- switch (choice)
- {
- case 1: mList.menuItem[i] = "Plain Egg";
- mList.menuPrice[i] = 1.45;
- break;
- case 2: mList.menuItem[i] = "Bacon and Egg";
- mList.menuPrice[i] = 2.45;
- break;
- case 3: mList.menuItem[i] = "Muffin\t";
- mList.menuPrice[i] = 0.99;
- break;
- case 4: mList.menuItem[i] = "French Toast";
- mList.menuPrice[i] = 1.99;
- break;
- case 5: mList.menuItem[i] = "Fruit Basket";
- mList.menuPrice[i] = 2.49;
- break;
- case 6: mList.menuItem[i] = "Cereal\t";
- mList.menuPrice[i] = 0.69;
- break;
- case 7: mList.menuItem[i] = "Coffee\t";
- mList.menuPrice[i] = 0.50;
- break;
- case 8: mList.menuItem[i] = "Tea\t";
- mList.menuPrice[i] = 0.75;
- break;
- }//end of switch
- }//end of for loop
- }//end of get data
- void printCheck(menuItemType & mList, int & c)
- {
- float price = 0.0, tax = 0.0, total = 0.0;
- cout << "\nWelcome to Johnny's Restaurant" << endl;
- for (int i = 0; i < c; i++)
- {
- cout << mList.menuItem[i] << "\t" << mList.menuPrice[i] << endl;
- price += mList.menuPrice[i];
- }
- tax = 0.05 * price;
- total = tax + price;
- cout << setprecision(2) << fixed;
- cout << "\nTax= $" << tax << endl;
- cout << "Amount Due= $" << total << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement