I have an assignment that requires me to use an array, menuList, of struct menuItemType with members string menuItem and double menuPrice. I have to display the menu, let the customer order, total the bill including tax and print the check. Function getData had to load the data into the array menuList. I am struggling with arrays of structs. Here is what I have so far. If someone could walk me through the process so I can understand how to do it and why, that would be great. I don't just want to get a good grade, I want to understand what I'm doing. Thanks.

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

//declare struct
struct menuItemType
{
	string menuItem;
	double menuPrice;
};

//declare function prototypes
void getData(menuItemType menuList[]);
void showMenu(menuItemType menuList[]);
void printCheck(menuItemType menuList[]);
double calctax(double sumSale, double taxRate);
double calctotal(double saleAmount, double taxAmount);

int main()
{
	//declare variables
	string menuItem;
	double price;
	double tax;
	double sumSale;
	double totSale;
	char response;

	//put information into array
	menuItemType menu[8];

	getData (menuList);

	//call show menu function
	showmenu();
	cout << "Would you like to order an item? " << endl;
	cin >> response >> endl;

	while(response == 'Y' || response == 'y')
	{
		cout << "Enter the first two letters of the "
			 << "item you wish to order ";
		cin >> menuItem;
		cout << endl;

		{
		if(menuItem == "PLA" || menuItem == "pla")//Plain Egg
		{
			sumSale += 1.45;
		}
		else if(menuItem == "BAC" || menuItem == "bac")//Bacon and Egg
		{
			sumSale += 2.45;
		}
		else if(menuItem == "MUF" || menuItem == "muf")//Muffin
		{
			sumSale += 0.99;
		}
		else if(menuItem == "FRE" || menuItem == "fre")//French Toast
		{
			sumSale += 1.99;
		}
		else if(menuItem == "FRU" || menuItem == "fru")//Fruit Basket
		{
			sumSale += 2.49;
		}
		else if(menuItem == "CER" || menuItem == "cer")//Cereal
		{
			sumSale += 0.69;
		}
		else if(menuItem == "COF" || menuItem == "cof")//Coffee
		{
			sumSale += 0.50;
		}
		else if(menuItem == "TEA" || menuItem == "tea")//Tea
		{
			sumSale += 0.75;
		}
		else
		{
			cout << "Invalid Entry. " << endl;
		}

		cout << "Order another item: Y or N ";
		cin >> response;
	}

	While(response != 'Y' || response != 'y')
	{
		//call the tax  calculation function
		tax = calctax(sumSales, rate);

		//call the total bill function
		total = calctotal(sumSales, tax);

		//call the printCheck function
		printcheck(menuList)


	return 0;
}

//function to get data into the array menuList
void getData(menuItemType menuList[])
{
}

//function to display menu
void showMenu(menuItemType menuList[])
{
	cout << "Plain Egg           $1.45 " << endl;
	cout << "Bacon and Egg       $2.45 " << endl;
	cout << "Muffin              $0.99 " << endl;
	cout << "French Toast        $1.99 " << endl;
	cout << "Fruit Basket        $2.49 " << endl;
	cout << "Cereal              $0.69 " << endl;
	cout << "Coffee              $0.50 " << endl;
	cout << "Tea                 $0.75 " << endl;
}

//function to calculate sales tax
double calctax(double sumSale, double taxRate)
{
	return (sumSale * taxRate);
}

//function to calculate the total bill
double calctotal(double saleAmount, double taxAmount)
{
	return (sumSale + tax);
}

//function to print check
void printCheck(menuItemType menuList[])
{
}

no errors!!..what should i do for you?..

I don't just want to get a good grade, I want to understand what I'm doing

alright..thats my girl..

I dont know how to use the getdata function to load the menu items into the array. also, my function defenitions are not complete. I'm not sure how to complete them because of the array. I'm a little overwhelmed. Do you think you could walk me throught it a little so that i can understand not just how to do it but why.

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