Here is the code after I made added loops and if statements. I now am passing the users choice to the printcheck function wrong. It says type int is incompatible with my struct menuItemType.
Code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct menuItemType
{
string menuItem;
double menuPrice;
};
const int NUMBER_OF_ROWS = 8;
const int NUMBER_OF_COLUMNS = 2;
double showMenu(menuItemType menuList[NUMBER_OF_ROWS]);
void getData(menuItemType menuList[NUMBER_OF_ROWS]);
double printCheck(menuItemType menuList[NUMBER_OF_ROWS]);
int main()
{
int choice;
menuItemType menuList[NUMBER_OF_ROWS];
getData(menuList);
showMenu(menuList);
printCheck(choice);
}
void getData(menuItemType menuList[NUMBER_OF_ROWS])
{
ifstream inFile;
inFile.open("C:\\Users\\Dylan\\Documents\\InfileTravischapter9Page629.txt");
for (int i = 0; i < 8; i++)
{
inFile >> menuList[i].menuItem
>> menuList[i].menuPrice;
}
}
double showMenu(menuItemType menuList[NUMBER_OF_ROWS])
{
menuItemType menuList;
getData(menuList);
int choice;
bool selectAnother;
for(int i=0; i < 8; i++)
{
cout << menuList->menuPrice << endl;
}
cout << "What would you like to eat, you can have up to one of each item on the menu" << endl;
cout << "Press the following keys to select your items" << endl;
cout << "1 = Plain\n2 = Bacon and Egg\n 3 = Muffin\n 4 = French Toast\n 5 = Fruit Basket \n 6 = Cereal \n 7 = Coffee \n 8 = Tea" << endl;
cin >> choice;
cout << "Would you like to select another item? Enter yes or no" << endl;
cin >> selectAnother;
if(selectAnother == 'yes')
{
cout << "What would you like to eat, you can have up to one of each item on the menu" << endl;
cout << "Press the following keys to select your items" << endl;
cout << "1 = Plain\n2 = Bacon and Egg\n 3 = Muffin\n 4 = French Toast\n 5 = Fruit Basket \n 6 = Cereal \n 7 = Coffee \n 8 = Tea" << endl;
cin >> choice;
cout << "Would you like to select another item? Enter yes or no" << endl;
cin >> selectAnother;
}
return 0;
}
double printCheck(int choice)
{
double bill;
double price;
double check;
showMenu(choice);
if(choice == 1)
price = 1.45;
if(choice == 2)
price = 2.45;
if(choice == 3)
price = .99;
if(choice == 4)
price = 1.99;
if(choice == 5)
price = 2.49;
if(choice == 6)
price = .69;
if (choice == 7)
price = .50;
if(choice == 8)
price = .75;
bill = bill + price;
check = bill * .05 + bill;
cout << "Your check is $" << check << endl;
}