954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need help on homework

This is what I have on my program so far. I do not know what to do next.

Thanks alot,
Kilo


// Write a program to help a local restaurant automate its breakfast billing
//system. Show the customer the different breakfast itmes offered by the
//restaurant. Allow the customer to select more than one item from the menu.
//Calculate and print the bill.
#include
#include
#include


using namespace std;

struct menuList //Define struct menuList with members
{
string Eggs;
string BaconandEggs;
string Muffin;
string FrenchToast;
string FruitBasket;
string Cereal;
string Coffee;
string Tea;
string price:
};
void getData();
void showMenu();
void printcheck();
int main()
{
menuList menuItemType; // declare variable

void getData();
menuItemList.Eggs; //Access a struct member components
menuItemList.BaconandEggs;
menuItemList.Muffins;
menuItemList.FrenchToast;
menuItemList.FruitBasket;
menuItemList.Cereal;
menuItemList.Coffee;
menuItemList.Tea;
menuItemList.price = 0.0;

void showMenu();
cin >> menuItemType.Eggs >> menuItemType.BaconandEggs;
cin >> menuItemType.Muffin;
cin >> menuItemType.FrenchToast;
cin >> menuItemType.FruitBasket;
cin >> menuItemType.Cereal;
cin>> menuItemType.Coffee;
cin >> menuItemType.Tea;



void printCheck();

system("PAUSE");
return EXIT_SUCCESS;
}

Kilo
Newbie Poster
1 post since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

1. where is menuItemList object declared?

2. why all those useless lines that access the structure but does nothing with them? For example: menuItemList.BaconandEggs; If it is supposed to be setting them to 0 -- it doesn't.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
struct menuList //Define struct menuList with members { string Eggs; string BaconandEggs; string Muffin; string FrenchToast; string FruitBasket; string Cereal; string Coffee; string Tea; string price: };


What are these variables supposed to contain? I suspect that you do not want to write out your complete menu in a struct, that would achieve very little except for a very long tedious program.
Remember: a struct is like a template for the type of information you want to store - Do not pre-empt the actual data it is going to contain!

Also, I suspect you want to use a numerical type for price.void getData();
void showMenu();
void printcheck();
OK - here you have 3 forward declarations of functions, but their definitions are inside your main() function - this is wrong, they must be declared outside main(), either before or after it. menuItemList.Eggs; //Access a struct member components
This line is doing nothing, letalone accessing anything, what do you intend this line to do? menuItemList.price = 0.0;
This is an error. assuming you mean "menuItem price" - its a string - you must change price to float, or preferably, double to do this. void showMenu();
cin >> menuItemType.Eggs >> menuItemType.BaconandEggs;
cin >> menuItemType.Muffin;
cin >> menuItemType.FrenchToast;
cin >> menuItemType.FruitBasket;
cin >> menuItemType.Cereal;
cin>> menuItemType.Coffee;
cin >> menuItemType.Tea;
I Already mentioned that this function must be declared outside main(). Aside from that - What are you asking your users to input? The name "ShowMenu" is very misleading and confusing - it doesn't show or output anything!
Quite the opposite, in fact - it asks for user input. Maybe GetMenuContents() would be a more appropriate name here.


think more carefully about the actual data you wish to store. storing price or other numerical information in a string is quite useless.

I suspect you'd be better of re-designing your data structures. In real terms, every item on a restaurant menu is a seperate entity with unique properties. These entities do not share any information with each another, so why relate them in a struct?

struct MenuEntry
{
  std::string name;
  double price;
}

A menu is a collection or list of all these entities. a C++ container such as "list" or "vector", would be well suited to the task of grouping all your entries together, and forming your Menu.

Bench
Posting Pro
577 posts since Feb 2006
Reputation Points: 307
Solved Threads: 63
 

i have a case study....
my prof said that we should display 10 random numbers without reaping the same number for example the screen will print numbers from 0-9 at this order

1 6 7 5 2 3 4 9 8 0

then when we exit the program it should pritn another random number... plss help i needed it very badly :sad: :sad: :sad:

tanx...

tomoyo_13m
Newbie Poster
3 posts since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

i have a case study.... my prof said that we should display 10 random numbers without reaping the same number for example the screen will print numbers from 0-9 at this order

1 6 7 5 2 3 4 9 8 0

then when we exit the program it should pritn another random number... plss help i needed it very badly :sad: :sad: :sad:

tanx...

OK... so, show us how far you've gotten with your program...

Bench
Posting Pro
577 posts since Feb 2006
Reputation Points: 307
Solved Threads: 63
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You