Language is C++.
I dont know how to take what the user orders and calculate their bill. I used a class. Heres my code: -
#include <iostream>
-
#include <string>
-
#include "Headerfile.h"
-
using namespace std;
-
-
int main ()
-
{
-
//This prints out the menu
-
Menu ChoosingAnItem;
-
ChoosingAnItem.menu();
-
-
//This asks the user what they would like to order
-
Menu ORDERING;
-
ORDERING.ordering();
-
-
struct Something {item, status, price}
-
-
-
return 0;
-
}
-
-
//********************************************
-
Header File
-
//******************************************
-
#include <string>
-
#include <iostream>
-
using namespace std;
-
-
class Menu
-
{
-
public:
-
string menu();
-
string ordering();
-
-
string removing();
-
string adding();
-
string printing();
-
float totalPrice();
-
string testing();
-
-
private:
-
string test;
-
};
-
//*****************************************
-
Implementation file
-
//*****************************************
-
#include <iostream>
-
#include "Headerfile.h"
-
using namespace std;
-
-
//***********************
-
//This is the menu the user sees
-
string Menu::menu()
-
{
-
string MENU;
-
printf (" --Menu--\n\n");
-
printf (" *Main course:\n");
-
printf (" 1. Tomato Brushetta\t\t6.29\n");
-
printf (" 2. Calamri Fritti\t\t8.29\n");
-
printf (" 3. Pesto Chicken Pizza\t9.99\n");
-
printf (" 4. Chicken Florentine\t\t9.99\n");
-
printf (" 5. Eggplant Parmesan\t\t10.29\n");
-
printf (" 6. Penne Rusitca\t\t13.29\n");
-
printf (" 7. Veal Marsal\t\t13.99\n");
-
printf (" 8. Grilled Halibut\t\t16.99\n\n");
-
printf (" *Drinks:\n");
-
printf (" 9. water\t\t\t2.00\n");
-
printf (" 10. italian soda\t\t2.50\n");
-
printf (" 11. wine\t\t\t7.50\n\n");
-
return MENU;
-
};
-
//**********************
-
string Menu::ordering()
-
{
-
string order;
-
printf( "What would you like to order?\n" );
-
return order;
-
};
-
//************************
-
string Menu::removing()
-
{
-
-
-
};
-
//************************
-
-
-
-
2 1415
I think what im stuck on is how to put that menu in a array.
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 -
string Menu::ordering()
-
{
-
string order;
-
printf( "What would you like to order?\n" );
-
return order;
-
};
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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...
|
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 :
|
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?
|
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...
| |
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...
|
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
|
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:
|
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
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |