473,669 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Turn order into bill C++

yue219
7 New Member
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 1415
yue219
7 New Member
I think what im stuck on is how to put that menu in a array.
Nov 6 '07 #2
sicarie
4,677 Recognized Expert Moderator Specialist
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
2117
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 is to process the contacts in a single-pass XSLT process. That is why the "document()" function is what I need. I call the "document()" XPath function from a "for-each" instruction.
4
7123
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 executed, other necessary Windows Services have been terminated before it can actually send the mail. I've updated my HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services registry DependOnService value including SMPTSVC and others. My hope is...
6
4782
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 should output like this :
10
2861
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 "problem" however the cursor no longer changes into the little hand when rolling over the link. Can I have both? No HREF and the little hand?
8
8064
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 it with a table and within the table a yes/no field would determine which box it would be in. An Update statement would be fired changing it from yes to no or vice versa and then refreshing the listboxes. This doesn't seem to scale very well as...
8
4183
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 send mail code is executed, other necessary Windows Services have been terminated before it can actually send the mail. I've updated my HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services registry DependOnService value including SMPTSVC and...
1
1633
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; linking object as if no debug info Thanks advanced, Bill
9
5309
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 table_a and table_b, that is, say you have this: Here is where the problem lies. I am required to be able to sort by 'Phil', no problem:
4
4258
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 defined in the IN clause, but unfortunately SQL is trying to be too helpful and sorts
0
8462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8586
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8658
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7405
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1787
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.