Hello World,

Can someone help me find this error. I'm trying to code for Johnny's Resturant. I need to show the items, allow the customer to select an item and calculate the bill. This is what I've done so far:
I need some assistance with the program... I've sedn how they get it to work using an array, but I can do it that way...Thanks

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
const int No_Of_Items = 8;
 struct menuItemType
{ string menuItem;
 double menuPrice;
};
void getData(ifstream & inFile, menuItemType mList[], int listSize);
void showMenu (menuItemType mList[], int listSize);
void printcheck(menuItemType mList [], int listSize, int cList[], int cListLength);
void makeselect (menuItemType mList[], int listSize, int cList [], int& cListLength);
Bool isItemselected(int cList [], int cListLength, int itemNo);
 int main()
{
 int menuItemType menuList[No_Of_Items];
 int choiceList [No_Of_Items];
 int choiceListLength;
 
 ifstream infile;
 ofstream outfile;
 
 infile.open(inputFile.f_menu.cpp());
 if (!infile)
 { 
  cout << "Cannot open the input file."
  << endl;
  return 1;
 }
 
 initialize (infile, menu, No_Of_Items);
 
 infile.close;
 infile.clear;
 
 getData(infile, menuList, No_Of_Items);
 showMenu(menuList,No_Of_Items);
 makeselect(menuList, No_Of_Items, choiceList, choiceLength);
 printCheck(menuList, No_Of_Items, choiceList, choiceLength);
return 0;
void getData(ifstream&, inFile, menuItemType mList[], int listSize)
{
 char ch;
 for (int=0; i < listSize; i++)
{
 Getline (inFile, mList[i].menu.Item);
 inFile >> mList[i].menuPrice;
 inFile.get(ch);
 }
{
void showMenu (menuItemType mList[], int listSize)
{
 cout << "Johnny's Resturant"<< endl;
 cout << "menu items" << endl;
 
 for (int i=0; l < listSize; l++)
 cout << i + 1":: << left << setw(15) << mList[1].menuItem"
 <<right<<" $ " <<mList[i].menuPrice << endl;
 cout << endl;
}
void printcheck(menuItemType mList[], int listSize, int cList [], int cListLength)
{
 int i;
 double salesTax;
 double amountDue = 0;
 
 cout <<"Welcome to Johnny's Resturant" << endl;
 for  (i = 0; i < cListLength; i++)
 {
  cout << left << setw(15) << mList [cList [i]].menuItem
   << right << " $" << setw(4) << mList[cList[i]].menuPrice
   << endl;
 
   amountDue + = mList[cList [i]].menuPrice;
   }
   salesTax = amountDue * .05;
   cout << left << setw (15) << "Tax" << right << " $"
   << salesTax << endl;
   amountDue = amountDue + salesTax;
   cout << left << setw(15) << "Amount Due" << right
     << " $" << amountDue << endl;
   }
void makeselection (menuItemType mList[], int listSize, 
   int cList [], int& cListLength)
{
 int selectionNo = 0;
 int itemNo;
 
 char response;
 
 cListLength = 0;
 
 cout << "You can make up to "  << listSize
   << " single order selections" << endl;
 cout << " Do you want to make selection Y/y (Yes), N/n (No): ";
 cin >> response;
 cout << endl;
 
 while ((response == 'Y' response == 'y') &&
   cListLength < 8)
{
 cout << "Enter item number: ";
 cin >> itemNo;
 cout << endl;
 
 if (!isItemSelected(cList, cListLength, itemNo))
  cList [cListLength++] = itemNo - 1;
 else
  cout << "Item already selected" << endl;
 
  cout << "Select another item Y/y (Yes), N/n (No0 : ";
  cin >> response;
  cout << endl;
 }
}
bool isItemSelected (int cList [], int cListLength, int itemNo)
{
 bool found = false;
 for ( int i=0; i< cListLength; i++)
  if (cList [i] == itemNo)
 {
  found = true;
  break;
 }
 return found;
}

>>I've sedn how they get it to work using an array, but I can do it that way...Thanks

do you mean you are not allowed to use arrays or you don't know how to use arrays ?

Where does main() start? I see some exceutable code that is not inside any function. Looks like you forgot to add the curly-braces for main() beginning on line 16.

She really didn't say yes or no to the arrays I just assume that were not supose to use them. Ok.. I'll check out line 16.

>>I've sedn how they get it to work using an array, but I can do it that way...Thanks

do you mean you are not allowed to use arrays or you don't know how to use arrays ?

Where does main() start? I see some exceutable code that is not inside any function. Looks like you forgot to add the curly-braces for main() beginning on line 16.

This article has been dead for over six months. Start a new discussion instead.