473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Turn order into bill C++

yue219
7
Language is C++.
I dont know how to take what the user orders and calculate their bill. I used a class. Heres my code:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3. #include "Headerfile.h"
  4. using namespace std;
  5.  
  6. int main ()
  7.     //This prints out the menu 
  8.     Menu ChoosingAnItem;
  9.     ChoosingAnItem.menu();
  10.  
  11.     //This asks the user what they would like to order
  12.     Menu ORDERING;
  13.     ORDERING.ordering();
  14.  
  15.     struct Something {item, status, price}
  16.  
  17.  
  18.     return 0;
  19. }
  20.  
  21. //********************************************
  22. Header File
  23. //******************************************
  24. #include <string>
  25. #include <iostream>
  26. using namespace std;
  27.  
  28. class Menu
  29. {
  30.     public:
  31.         string menu();
  32.         string ordering();
  33.  
  34.         string removing();
  35.         string adding();
  36.         string printing();
  37.         float totalPrice();
  38.         string testing();
  39.  
  40.     private:
  41.         string test;
  42. };
  43. //*****************************************
  44. Implementation file
  45. //*****************************************
  46. #include <iostream>
  47. #include "Headerfile.h"
  48. using namespace std;
  49.  
  50. //***********************
  51. //This is the menu the user sees 
  52. string Menu::menu()
  53. {
  54.     string MENU;
  55.     printf ("        --Menu--\n\n");
  56.     printf ("  *Main course:\n");
  57.     printf ("  1. Tomato Brushetta\t\t6.29\n");
  58.     printf ("  2. Calamri Fritti\t\t8.29\n");
  59.     printf ("  3. Pesto Chicken Pizza\t9.99\n");
  60.     printf ("  4. Chicken Florentine\t\t9.99\n");
  61.     printf ("  5. Eggplant Parmesan\t\t10.29\n");
  62.     printf ("  6. Penne Rusitca\t\t13.29\n");
  63.     printf ("  7. Veal Marsal\t\t13.99\n");
  64.     printf ("  8. Grilled Halibut\t\t16.99\n\n");
  65.     printf ("  *Drinks:\n");
  66.     printf ("  9. water\t\t\t2.00\n");
  67.     printf ("  10. italian soda\t\t2.50\n");
  68.     printf ("  11. wine\t\t\t7.50\n\n");
  69.     return MENU;
  70. };
  71. //**********************
  72. string Menu::ordering()
  73. {
  74.     string order;
  75.     printf( "What would you like to order?\n" );
  76.     return order;
  77. };
  78. //************************
  79. string Menu::removing()
  80. {
  81.  
  82.  
  83. };
  84. //************************
  85.  
  86.  
  87.  
  88.  
Nov 6 '07 #1
2 1408
yue219
7
I think what im stuck on is how to put that menu in a array.
Nov 6 '07 #2
sicarie
4,677 Expert Mod 4TB
Do you want to put the menu in an array, or do you want to receive an order? YOu asked two different questions there. The menu would go in an array of strings exactly as it is in your print statements now. You could remove the numbers and use the array index + 1 (which I would recommend so you don't have to worry about numbers getting out of order or needing to keep track of them), and then you could just print it out with a for loop.

as for ordering, right now you just say
Expand|Select|Wrap|Line Numbers
  1. string Menu::ordering()
  2. {
  3.     string order;
  4.     printf( "What would you like to order?\n" );
  5.     return order;
  6. };
  7.  
So you're not even reading anything in, you're just returning an empty string. I would recommend setting it up so that the user (waiter) puts in a number. You could have them type it in, but then you have to worry about cases and misspellings, etc... Then you can match the number with a menu option, or even a price if you put it in a map... That's sort of up to you.
Nov 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Phil | last post by:
Hi everybody, I am a XSLT beginner and the following problem really makes me crazy ! I have a main "contacts.xml" document which contains references to several contact data XML files. My aim...
4
by: Bill Sonia | last post by:
I'm written a Windows Service to send e-mails on events like OnStart, OnStop, OnShutDown using System.Web.Mail. It works for everything but OnShutdown. My guess is that once my send mail code is...
6
by: usenet | last post by:
I'm trying to figure out how I can sort records alphabetically by almost "blending" two fields. SELECT city, county FROM fullist WHERE type = 'city' or type = 'county' ORDER BY ???; It...
10
by: Bill H | last post by:
I used a bit of JS on a page that is fairly long and didn't like the way that <A HREF='#' ONCLICK=\"... refreshed the page to the top. Removing the HREF (<A ONCLICK=\"...) solved my...
8
by: Bill | last post by:
I'm trying to create a wizardlike interface using a couple listboxes. I know you've seen it before. You double click on an item in one listbox and it "moves" it to the other. I used to approach...
8
by: Bill Sonia | last post by:
I've written a Windows Service to send e-mails on events like OnStart, OnStop, OnShutDown using System.Web.Mail. It works for everything but OnShutdown. My guess is that for OnShutDown, once my...
1
by: Bill Sun | last post by:
Hi, Who can tell me how to turn off the annoying link warning, like this: Xxxx.lib(read_dose.obj) : warning LNK4204: '......xxxx\vc70.pdb' is missing debugging information for referencing module;...
9
by: phillip.s.powell | last post by:
Ok, you have three tables. You're supposed to be able to not only sort (ORDER BY) according to a_name, no problem, but you must also have the ability to sort (ORDER BY) the relationship between...
4
by: Yobbo | last post by:
Hi All My query is as follows: SELECT STRINGTEXT, TOKENID FROM WEBSTRINGS WHERE TOKENID IN (6,20,234,19,32,4,800,177) All I want is my resultset to come back in the order that I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.