Hi, Long time lurker, first time poster! Basically here is my assignment, number 3
http://books.google.com/books?id=20xVrpISzoYC&lpg=PA27&ots=llLlOPBIRL&dq=cout%20%3C%3C%20%22this%20is%20Exercise%2016.%22%3C%3C%20endl%3B%20%20%20%20cout%20%3C%3C%20%22In%20C%2B%2B%2C%20the%20multiplication&pg=PA638#v=onepage&q&f=false

and so far here is what I got, and I really am stuck on this, if you can help would be great:

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



using namespace std; 



struct menuItemType 

{ 
   string menuItem; 
   double menuPrice; 
}; 
void getData(menuItemType placepicks[9]); 
void printCheck(menuItemType printpicks[]); 
void showMenu();

int main() 

{ 
  showMenu(); 
   menuItemType menuList[9]; 
   menuItemType picks[9]; 
   getData(picks); 
   printCheck(picks); 

    
  
   return 0; 
} 

 
void showMenu() 
{ 
	cout << "______ Resturant - The Menu for Today" << endl; 
	cout << "1.Plain Egg-----1.45" << endl; 
	cout << "2.Bacon and Egg-2.45" << endl; 
	cout << "3.Muffin--------0.99" << endl; 
	cout << "4.French Toast--1.99" << endl; 
	cout << "5.Fruit Basket--2.49" << endl; 
	cout << "6.Cereal--------0.69" << endl; 
	cout << "7.Coffee--------0.50" << endl; 
	cout << "8.Tea-----------0.75" << endl;  
	cout << "9. DONE" << endl;
} 

 
void getData(menuItemType placepicks[9]) 
{ 
	menuItemType menuList[9]; 
	menuList[0].menuItem = "Plain Egg";      
	menuList[1].menuItem = "Bacon and Egg"; 
	menuList[2].menuItem = "Muffin";          
	menuList[3].menuItem = "French Toast";      
	menuList[4].menuItem = "Fruit Basket"; 
	menuList[5].menuItem = "Cereal"; 
	menuList[6].menuItem = "Coffee"; 
	menuList[7].menuItem = "Tea";
	menuList[8].menuItem = "Done"; 

	menuList[0].menuPrice = 1.45; 
	menuList[1].menuPrice = 2.45; 
	menuList[2].menuPrice = 0.99; 
	menuList[3].menuPrice = 1.99; 
	menuList[4].menuPrice = 2.49; 
	menuList[5].menuPrice = 0.69; 
	menuList[6].menuPrice = 0.50; 
	menuList[7].menuPrice = 0.75;
	menuList[8].menuPrice = 0.00;  

	cout << "Whaddya have today? Pick a number " <<endl; 
    int answer; 
   
   for(answer = 0; answer < 7; answer++)	
   {	   cin >> menuList[answer];
    	 if(menuList[answer] = 8)
		 			break;
	}
     
   
} 

 
void printCheck(menuItemType printpicks[]) 
{ 
	const double rateOfTax = 0.05; 
	int a = 0;
	double amountDue = 0;
	double tax; 
	
	cout << endl;

	cout << "heres your order " << endl; 
	cout << endl;

	/* display the orders with the price*/
	// show the total price//
	//multiply the total price to .05, add those together and then show the final price//

}
Fbody commented: Could have been more clear about what the issue(s) is/were, but overall not a horrible first post. +1

Recommended Answers

All 2 Replies

Create a container to keep all the selections in it. The container may have any number of items in it. If you have been advised that no order will have more than 7 items associated with it, so be it, but it could have 1 or 3 or 4 or 7 so don't assume it will have no more and no less than 7 items. Then when the customer has completed the order you can loop through the container representing the order and print out the items, keep track of the total price of the items, calculate the tax and add the tax to the price of the items to get the total cost of the order. This can all be done using arrays, but be sure the arrays are big enough to be able to hold any given reasonable order, say 1000 items or so (unless you've been told that the maximum number of items in any given order will some specified value).

Here's a hint:
You need to use parallel arrays here. The first is the menu items themselves, the second is a "counter" or "distribution" array. The counter array would have 1 integer element (initialized to 0) for each menu item. Then, as the customer orders items, you increment the appropriate element in the counter array.

That should get you headed in the correct direction for now.

Basic idea:

const int RANGE = 8;
int inputValue = 0;
int distribution[RANGE] = {0};

cout << "Enter a number from 0 - " << RANGE - 1 << ": ";
cin >> inputValue;

while (inputValue >=0 && inputValue < RANGE) {

  distribution[inputValue]++;

  cout << "Enter a number from 0 - " << RANGE - 1 << ": ";
  cin >> inputValue;
}

for (int i = 0; i < RANGE; i++) {
  cout << i << " was entered " << distribution[i] << " times." << endl;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.