Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <iomanip>
- using namespace std;
- struct menuType {
- string Item;
- double price;
- };
- void outputMenu(menuType menuList[], int);
- void getdata(menuType menuList[]);
- int main() {
- const int item = 8;
- menuType menuList[item];
- getdata(menuList);
- outputMenu(menuList, item);
- 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.Item = 2.45;
- Muffin.Item = 0.99;
- FrenchToast.price = 1.99;
- FruitBasket.Item = 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 outputMenu(menuType menuList[], int x) {
- for (int i = 0; i < x; i++) {
- cout << setw(2) << left << "[" << i++ << "]";
- cout << menuList[i].Item << endl;
- cout << "$" << menuList[i].price << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement