Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <iomanip>
- #include <vector>
- using namespace std;
- struct menuType {
- string Item;
- double price;
- };
- void showMenu( menuType menuList[], int );
- void getdata( menuType menuList[] );
- void printCheck(menuType menuList[], int, double );
- vector<int> askOrder();
- int main()
- {
- const int item = 8;
- const double tax = 0.05;
- int orderSelect = 0;
- bool order = true;
- int choice;
- int selection = 0;
- int menuOrder[item];
- menuType menuList[item];
- getdata(menuList);
- showMenu(menuList, item);
- printCheck(menuList, selection, tax);
- return 0;
- }
- void getdata( menuType menuList[] )
- {
- //declare variable
- menuType PlainEgg;
- menuType BaconEgg;
- menuType Muffin;
- menuType FrenchToast;
- menuType FruitBasket;
- menuType Cereal;
- menuType Coffee;
- menuType Tea;
- //assign name to each item
- PlainEgg.Item = "Plain Egg";
- BaconEgg.Item = "Bacon Egg";
- Muffin.Item = "Muffin";
- FrenchToast.Item = "French Toast";
- FruitBasket.Item = "Fruit Basket";
- Cereal.Item = "Cereal";
- Coffee.Item = "Coffee";
- Tea.Item = "Tea";
- //assign price to each item
- PlainEgg.price = 1.45;
- BaconEgg.price = 2.45;
- Muffin.price = 0.99;
- FrenchToast.price = 1.99;
- FruitBasket.price = 2.49;
- Cereal.price = 0.69;
- Coffee.price = 0.50;
- Tea.price = 0.75;
- //put variable into array
- menuList[0] = PlainEgg;
- menuList[1] = BaconEgg;
- menuList[2] = Muffin;
- menuList[3] = FrenchToast;
- menuList[4] = FruitBasket;
- menuList[5] = Cereal;
- menuList[6] = Coffee;
- menuList[7] = Tea;
- }
- void showMenu( menuType menuList[], int x )
- {
- for( int i = 0; i < x; i++ )
- {
- cout << left << "[" << i+1 << "]";
- cout << menuList[i].Item;
- cout.width(6);
- cout <<"\t" << "\t"<< "\t" << "$" << menuList[i].price << endl;
- }
- }
- vector<int> askOrder() {
- while ture;
- cin << order;
- vector < int > history;
- history.push_back(order)
- if order >= 1 && order < 9
- return history;
- }
- //to calculate the bill
- void printCheck(menuType menuList[], int seleciton, double tax, int menuOder[], int item) {
- cout << "welcome to Johns restaurant" << endl;
- cout << "Please select your item and enter 9 to exit" << endl;
- menuList->Item;
- int total;
- int selections = 0;
- int item = 8;
- int menuOrder[8];
- while (selections != 9)
- {
- double tax=0.05;
- double total = 0 ;
- double itemPrice= 0 ;
- total = itemPrice + tax *itemPrice;
- cout << "Enter your selections: ";
- selections += selections;
- cin >> selections;
- switch (selections)
- {
- case 9:
- break;
- case 1:
- cout << menuList[0].Item << setw(14) << " " << "$1.45";
- break;
- case 2:
- cout << menuList[1].Item << setw(10) << " " << "$2.45";
- break;
- case 3:
- cout << menuList[2].Item << setw(17) << " " << "$0.99";
- break;
- case 4:
- cout << menuList[3].Item << setw(11) << " " << "$1.99";
- break;
- case 5:
- cout << menuList[4].Item << setw(11) << " " << "$2.49";
- break;
- case 6:
- cout << menuList[5].Item << setw(17) << " " << "$0.69";
- break;
- case 7:
- cout << menuList[6].Item << setw(17) <<" " << "$0.50";
- break;
- case 8:
- cout << menuList[7].Item << setw(20) <<" " << "$0.75";
- break;
- default:
- cout << "Selections must be between 1 and 8\n";
- break;
- }
- }
- bool order = true;
- cout << "Thanks for eating at Bob Evans!"
- cout << "Customer check: " << endl;
- total = total + tax;
- cout << "\nWelcome to Josh's Restaurant" << endl;
- cout << "Tax" << setw(10) << endl;
- cout << "Amount Due" << setw(10) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement