Hi, I guess I'll post here with my problem as well my introduction. I've coded in Java in high school for 2 years but my teacher was horrible so I decided to wait till college to take another programming class. Well I'm Programming Fundamentals and have been assigned a program in which we have to code a menu...

Here are the "Instructions:"
1. Create the menu below.
2. You are to implement the “switch” structure and “while looping” structure as well as the “decision (if)” structure for this program.
3. All code is to be logically broken down into appropriate user-defined functions to accomplish the necessary tasks.
4. The menu continues to display until the user enters a valid menu selection this will be done through the default switch statement.
5. When a user makes a valid selection he has the option to select another item from the menu until he is finished ordering at which time his bill will be created and tax of 7.5% added. You are to generate the output below.

I have spent the past few hours figuring everything out since I've missed the past 2 classes. The only problem I seem to be having is ending the program by hitting 'E'. If anyone has any suggestions, feel free to comment or whatever.

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
	int choice;
	int tacoQuant=0;
	int enchQuant=0;
	int tamaQuant=0;
	int nachQuant=0;
	int drnkQuant=0;
	double subTotal;
	double tax;
	double totalDue;
	double tacoTotal=0;
	double enchTotal=0;
	double tamaTotal=0;
	double nachTotal=0;
	double drnkTotal=0;
	
	cout<<"			Welcome to Daniel's Mexicafeteria!"<<endl;
	cout<<"Please continue to make all your selections by using the item number on the left"<<endl;
	cout<<"When you are finished type 'E' to exit."<<endl;
	cout<<endl;
	cout<<"..................................MENU........................................"<<endl;
	cout<<"Item# Description--------------------------------------------------------Price"<<endl;
	cout<<"______________________________________________________________________________"<<endl;
	cout<<"[100] Taco dinner:  2 tacos, rice and beans...............................5.95"<<endl;
	cout<<endl;
	cout<<"[200] Enchilada dinner:  2 cheese enchiladas, rice and beans..............6.95"<<endl;
	cout<<endl;
	cout<<"[300] Tamale dinner:  2 pork tamales, rice and beans......................4.95"<<endl;
	cout<<endl;
	cout<<"[400] Loaded nachos: chips with beef or chicken, cheese and jalapenos.....3.95"<<endl;
	cout<<endl;
	cout<<"[500] DRINKS one-size and free refills......................................95"<<endl;
	cout<<endl;

	while(choice=100||200||300||400||500){
	cin>>choice;

	switch (choice)
	{
	case 100:
		tacoQuant=tacoQuant+1;
		tacoTotal=tacoQuant*5.95;
		break;
	case 200:
		enchQuant=enchQuant+1;
		enchTotal=enchQuant*6.95;
		break;
	case 300:
		tamaQuant=tamaQuant+1;
		tamaTotal=tamaQuant*4.95;
		break;
	case 400:
		nachQuant=nachQuant+1;
		nachTotal=nachQuant*3.95;
		break;
	case 500:
		drnkQuant=drnkQuant+1;
		drnkTotal=drnkQuant*.95;
		break;
	default:
		system("cls");
		system("color A");
		cout<<endl;
		cout<<endl;
		cout<<"You have ordered the following:"<<endl;
		cout<<"___________________"<<endl;
		if(tacoQuant!=0){
			cout<<tacoQuant<<"  #100      "<<tacoTotal<<endl;
		}
		if(enchQuant!=0){
			cout<<enchQuant<<"  #200      "<<enchTotal<<endl;
		}
		if(tamaQuant!=0){
			cout<<tamaQuant<<"  #300      "<<tamaTotal<<endl;
		}
		if(nachQuant!=0){
			cout<<nachQuant<<"  #400      "<<nachTotal<<endl;
		}
		if(drnkQuant!=0){
			cout<<drnkQuant<<"  #500      "<<drnkTotal<<endl;
		}
		cout<<fixed<<setprecision(2)<<endl;
		cout<<"___________________"<<endl;
		subTotal=(tacoTotal+enchTotal+tamaTotal+nachTotal+drnkTotal);
		tax=(subTotal*.075);
		totalDue=(subTotal+tax);
		cout<<"Subtotal     "<<subTotal<<endl;
		cout<<"Tax          "<<tax<<endl;
		cout<<"___________________"<<endl;
		cout<<"Total Due    "<<totalDue<<endl;
	}
	}
		
return 0;
}
Ancient Dragon commented: Thanks for taking the time to read the rules and use code tags correctly :) +25

>>since I've missed the past 2 classes
Don't do that! you will fall behind real fast by missing classes.

>>while(choice=100||200||300||400||500){
>> cin>>choice;
I don't think you want to make that a while statement. Move the menu lines 23-39 into another function -- maybe named menu() -- so that main() will be easier to write. Then write a loop that include menu()

bool done = false;
while( !done)
{
     int choice = menu();
     switch(choice)
    {
case 100:
   done = true;
   break;
case 200:
   done = true;
    break;
case 300:
   done = true;
    break;
case 400:
   done = true;
   break;
default:
   cout << "invalid choice\n";
   break;   

    }
}

How would I go about making the menu into a function?

I tried this: (Is this correct?)
void menu(){
MENU TEXT HERE
}

Also when I'm doing to use menu in main, how do I "call upon it?" to display my menu?

That works, though it doesn't match what Ancient Dragon had in mind. His idea has the menu function also asking for the choice from the user. You could have a function that just displays it or one like his that asks for the choice as well. If you want to ask for the choice too, as Ancient Dragon suggested, your function header would be something like this:

int menu ();

The function would be this:

int menu ()
{
    // cout statements with menu choices
    int choice;
    cin >> choice;
    return choice;
}

Call the function as Ancient Dragon recommended in his post.

Blegh.. I've changed it a little but it's still iffy. It's probably because I don't understand creating functions very well, I've been reading about it in my book but still...

When I run it, it only asks once and then proceeds to the output at the bottom. I think I have this loop wrong.

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int menu()
{
	cout<<"			Welcome to Daniel's Mexicafeteria!"<<endl;
	cout<<"Please continue to make all your selections by using the item number on the left"<<endl;
	cout<<"When you are finished type 'E' to exit."<<endl;
	cout<<endl;
	cout<<"..................................MENU........................................"<<endl;
	cout<<"Item# Description--------------------------------------------------------Price"<<endl;
	cout<<"______________________________________________________________________________"<<endl;
	cout<<"[100] Taco dinner:  2 tacos, rice and beans...............................5.95"<<endl;
	cout<<endl;
	cout<<"[200] Enchilada dinner:  2 cheese enchiladas, rice and beans..............6.95"<<endl;
	cout<<endl;
	cout<<"[300] Tamale dinner:  2 pork tamales, rice and beans......................4.95"<<endl;
	cout<<endl;
	cout<<"[400] Loaded nachos: chips with beef or chicken, cheese and jalapenos.....3.95"<<endl;
	cout<<endl;
	cout<<"[500] DRINKS one-size and free refills......................................95"<<endl;
	cout<<endl;
	int choice;
    cin >> choice;
    return choice;
}

int main()
{
	int tacoQuant=0;
	int enchQuant=0;
	int tamaQuant=0;
	int nachQuant=0;
	int drnkQuant=0;
	double subTotal;
	double tax;
	double totalDue;
	double tacoTotal=0;
	double enchTotal=0;
	double tamaTotal=0;
	double nachTotal=0;
	double drnkTotal=0;


	bool done = false;
	while(!done)
	{
		int choice = menu();
		switch(choice)
    {
	case 100:
		tacoQuant=tacoQuant+1;
		tacoTotal=tacoQuant*5.95;
		done = true;
		break;
	case 200:
		enchQuant=enchQuant+1;
		enchTotal=enchQuant*6.95;
		done = true;
		break;
	case 300:
		tamaQuant=tamaQuant+1;
		tamaTotal=tamaQuant*4.95;
		done = true;
		break;
	case 400:
		nachQuant=nachQuant+1;
		nachTotal=nachQuant*3.95;
		done = true;
		break;
	case 500:
		drnkQuant=drnkQuant+1;
		drnkTotal=drnkQuant*.95;
		done = true;
		break;
	default:
		cout << "invalid choice\n";
		break;   

    }
} 
		system("cls");
		system("color A");
		cout<<endl;
		cout<<endl;
		cout<<"You have ordered the following:"<<endl;
		cout<<"___________________"<<endl;
		if(tacoQuant!=0){
			cout<<tacoQuant<<"  #100      "<<tacoTotal<<endl;
		}
		if(enchQuant!=0){
			cout<<enchQuant<<"  #200      "<<enchTotal<<endl;
		}
		if(tamaQuant!=0){
			cout<<tamaQuant<<"  #300      "<<tamaTotal<<endl;
		}
		if(nachQuant!=0){
			cout<<nachQuant<<"  #400      "<<nachTotal<<endl;
		}
		if(drnkQuant!=0){
			cout<<drnkQuant<<"  #500      "<<drnkTotal<<endl;
		}
		cout<<fixed<<setprecision(2)<<endl;
		cout<<"___________________"<<endl;
		subTotal=(tacoTotal+enchTotal+tamaTotal+nachTotal+drnkTotal);
		tax=(subTotal*.075);
		totalDue=(subTotal+tax);
		cout<<"Subtotal     "<<subTotal<<endl;
		cout<<"Tax          "<<tax<<endl;
		cout<<"___________________"<<endl;
		cout<<"Total Due    "<<totalDue<<endl;
		
return 0;
}

Ah, looks like you are supposed to enter 100, 200, 300, 400, 500, or 'E' while looking at the menu. 100 through 500 keeps prompting the menu again and again, while adding to the order, then 'E' exits. O.K., not a huge problem, but is it possible to change it from 100 through 500 to 1 through 5? If it is, make the menu function return a char, so it'll be the same except the header will be this:

char menu ();

and you will change "int" to "char" everywhere in the function. You'll also change choice from "int" to "char" in your while loop and you'll put all of your options in single parentheses. You'll add an option for 'E' in your switch statement.

bool done = false;
	while(!done)
	{
		char choice = menu();
		switch(choice)
    {
	case '1':
		tacoQuant=tacoQuant+1;
		tacoTotal=tacoQuant*5.95;
		//done = true;
		break;
	case '2':
		enchQuant=enchQuant+1;
		enchTotal=enchQuant*6.95;
		//done = true;
		break;
	case '3':
		tamaQuant=tamaQuant+1;
		tamaTotal=tamaQuant*4.95;
		//done = true;
		break;
	case '4':
		nachQuant=nachQuant+1;
		nachTotal=nachQuant*3.95;
		//done = true;
		break;
	case '5':
		drnkQuant=drnkQuant+1;
		drnkTotal=drnkQuant*.95;
		//done = true;
		break;
        case 'E':
               done = true;
               break;
	default:
		cout << "invalid choice\n";
		break;   

    }

If you are supposed to repeatedly go through the menu, don't set done to true for options 1 through 5. Delete those lines. I've commented them out above. This will keep you going through the loop over and over until you press 'E'.

Well, I emailed my teacher and asked her whether or not I can use my own functions and she said she didn't want me to since she hasn't taught them in class yet. So I took it out but still managed to get the program working pretty well. Only one minor crash that is caused when you enter something other than 100,200,300,400,500,E. I assume it's due to the string and character comparison and nothing is stored in char choice and when it's executed the switch statement has nothing to retrieve from char choice. Oh well, I don't think my teacher will really mind.

I appreciate all the help from Ancient Dragon and Vernon Dozier. Thanks for everything guys, I'll be sure to keep up with my class studies and stay active to learn some more.

Here is the source if anyone is interested in letting me know why it crashes.

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
	int tacoQuant=0;
	int enchQuant=0;
	int tamaQuant=0;
	int nachQuant=0;
	int drnkQuant=0;
	double subTotal;
	double tax;
	double totalDue;
	double tacoTotal=0;
	double enchTotal=0;
	double tamaTotal=0;
	double nachTotal=0;
	double drnkTotal=0;
	
	system("color D");
	cout<<"			Welcome to Daniel's Mexicafeteria!"<<endl;
	cout<<"Please continue to make all your selections by using the item number on the left"<<endl;
	cout<<"When you are finished type 'E' to exit."<<endl;
	cout<<endl;
	cout<<"NOTE: Any selection other than Item# or 'E' will result in a crash"<<endl;
	cout<<endl;
	cout<<"..................................MENU........................................"<<endl;
	cout<<"Item# Description--------------------------------------------------------Price"<<endl;
	cout<<"______________________________________________________________________________"<<endl;
	cout<<"[100] Taco dinner:  2 tacos, rice and beans...............................5.95"<<endl;
	cout<<endl;
	cout<<"[200] Enchilada dinner:  2 cheese enchiladas, rice and beans..............6.95"<<endl;
	cout<<endl;
	cout<<"[300] Tamale dinner:  2 pork tamales, rice and beans......................4.95"<<endl;
	cout<<endl;
	cout<<"[400] Loaded nachos: chips with beef or chicken, cheese and jalapenos.....3.95"<<endl;
	cout<<endl;
	cout<<"[500] DRINKS one-size and free refills......................................95"<<endl;
	cout<<endl;

	bool done = false;
	while(!done)
	{
		char choice;
		string subChoice ="";
		getline(cin,subChoice);

		if(subChoice=="100"){
			choice='1';}
		if(subChoice=="200"){
			choice='2';}
		if(subChoice=="300"){
			choice='3';}
		if(subChoice=="400"){
			choice='4';}
		if(subChoice=="500"){
			choice='5';}
		if(subChoice=="E"){
			choice='E';}

	switch(choice)
    {
	case '1':
		tacoQuant=tacoQuant+1;
		tacoTotal=tacoQuant*5.95;
		break;
	case '2':
		enchQuant=enchQuant+1;
		enchTotal=enchQuant*6.95;
		break;
	case '3':
		tamaQuant=tamaQuant+1;
		tamaTotal=tamaQuant*4.95;
		break;
	case '4':
		nachQuant=nachQuant+1;
		nachTotal=nachQuant*3.95;
		break;
	case '5':
		drnkQuant=drnkQuant+1;
		drnkTotal=drnkQuant*.95;
		break;
	case 'E':
		done = true;
		break;  
	default:
		cout << "invalid choice\n";
		break;

    }
} 
		
		system("color A");
		cout<<endl;
		cout<<endl;
		cout<<"You have ordered the following:"<<endl;
		cout<<"___________________"<<endl;
		if(tacoQuant!=0){
			cout<<tacoQuant<<"  #100      "<<tacoTotal<<endl;
		}
		if(enchQuant!=0){
			cout<<enchQuant<<"  #200      "<<enchTotal<<endl;
		}
		if(tamaQuant!=0){
			cout<<tamaQuant<<"  #300      "<<tamaTotal<<endl;
		}
		if(nachQuant!=0){
			cout<<nachQuant<<"  #400      "<<nachTotal<<endl;
		}
		if(drnkQuant!=0){
			cout<<drnkQuant<<"  #500      "<<drnkTotal<<endl;
		}
		cout<<fixed<<setprecision(2)<<endl;
		cout<<"___________________"<<endl;
		subTotal=(tacoTotal+enchTotal+tamaTotal+nachTotal+drnkTotal);
		tax=(subTotal*.075);
		totalDue=(subTotal+tax);
		cout<<"Subtotal     "<<subTotal<<endl;
		cout<<"Tax          "<<tax<<endl;
		cout<<"___________________"<<endl;
		cout<<"Total Due    "<<totalDue<<endl;
		
return 0;
}

Well, I emailed my teacher and asked her whether or not I can use my own functions and she said she didn't want me to since she hasn't taught them in class yet. So I took it out but still managed to get the program working pretty well. Only one minor crash that is caused when you enter something other than 100,200,300,400,500,E. I assume it's due to the string and character comparison and nothing is stored in char choice and when it's executed the switch statement has nothing to retrieve from char choice. Oh well, I don't think my teacher will really mind.

I appreciate all the help from Ancient Dragon and Vernon Dozier. Thanks for everything guys, I'll be sure to keep up with my class studies and stay active to learn some more.

Here is the source if anyone is interested in letting me know why it crashes.

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
	int tacoQuant=0;
	int enchQuant=0;
	int tamaQuant=0;
	int nachQuant=0;
	int drnkQuant=0;
	double subTotal;
	double tax;
	double totalDue;
	double tacoTotal=0;
	double enchTotal=0;
	double tamaTotal=0;
	double nachTotal=0;
	double drnkTotal=0;
	
	system("color D");
	cout<<"			Welcome to Daniel's Mexicafeteria!"<<endl;
	cout<<"Please continue to make all your selections by using the item number on the left"<<endl;
	cout<<"When you are finished type 'E' to exit."<<endl;
	cout<<endl;
	cout<<"NOTE: Any selection other than Item# or 'E' will result in a crash"<<endl;
	cout<<endl;
	cout<<"..................................MENU........................................"<<endl;
	cout<<"Item# Description--------------------------------------------------------Price"<<endl;
	cout<<"______________________________________________________________________________"<<endl;
	cout<<"[100] Taco dinner:  2 tacos, rice and beans...............................5.95"<<endl;
	cout<<endl;
	cout<<"[200] Enchilada dinner:  2 cheese enchiladas, rice and beans..............6.95"<<endl;
	cout<<endl;
	cout<<"[300] Tamale dinner:  2 pork tamales, rice and beans......................4.95"<<endl;
	cout<<endl;
	cout<<"[400] Loaded nachos: chips with beef or chicken, cheese and jalapenos.....3.95"<<endl;
	cout<<endl;
	cout<<"[500] DRINKS one-size and free refills......................................95"<<endl;
	cout<<endl;

	bool done = false;
	while(!done)
	{
		char choice;
		string subChoice ="";
		getline(cin,subChoice);

		if(subChoice=="100"){
			choice='1';}
		if(subChoice=="200"){
			choice='2';}
		if(subChoice=="300"){
			choice='3';}
		if(subChoice=="400"){
			choice='4';}
		if(subChoice=="500"){
			choice='5';}
		if(subChoice=="E"){
			choice='E';}

	switch(choice)
    {
	case '1':
		tacoQuant=tacoQuant+1;
		tacoTotal=tacoQuant*5.95;
		break;
	case '2':
		enchQuant=enchQuant+1;
		enchTotal=enchQuant*6.95;
		break;
	case '3':
		tamaQuant=tamaQuant+1;
		tamaTotal=tamaQuant*4.95;
		break;
	case '4':
		nachQuant=nachQuant+1;
		nachTotal=nachQuant*3.95;
		break;
	case '5':
		drnkQuant=drnkQuant+1;
		drnkTotal=drnkQuant*.95;
		break;
	case 'E':
		done = true;
		break;  
	default:
		cout << "invalid choice\n";
		break;

    }
} 
		
		system("color A");
		cout<<endl;
		cout<<endl;
		cout<<"You have ordered the following:"<<endl;
		cout<<"___________________"<<endl;
		if(tacoQuant!=0){
			cout<<tacoQuant<<"  #100      "<<tacoTotal<<endl;
		}
		if(enchQuant!=0){
			cout<<enchQuant<<"  #200      "<<enchTotal<<endl;
		}
		if(tamaQuant!=0){
			cout<<tamaQuant<<"  #300      "<<tamaTotal<<endl;
		}
		if(nachQuant!=0){
			cout<<nachQuant<<"  #400      "<<nachTotal<<endl;
		}
		if(drnkQuant!=0){
			cout<<drnkQuant<<"  #500      "<<drnkTotal<<endl;
		}
		cout<<fixed<<setprecision(2)<<endl;
		cout<<"___________________"<<endl;
		subTotal=(tacoTotal+enchTotal+tamaTotal+nachTotal+drnkTotal);
		tax=(subTotal*.075);
		totalDue=(subTotal+tax);
		cout<<"Subtotal     "<<subTotal<<endl;
		cout<<"Tax          "<<tax<<endl;
		cout<<"___________________"<<endl;
		cout<<"Total Due    "<<totalDue<<endl;
		
return 0;
}

It didn't "crash" on me (i.e. program didn't end prematurely), but it did give bad results. Simple fix. Initialize choice to some illegal value, like 'B' for "bad data". If the data is illegal, it will stay as 'B' and the default option in the switch will kick in, which is what you want. Just change line 46 from:

char choice;

to

char choice = 'B';

Also, the string comparisons worked and often will, but using == to compare strings can be dangerous. Consider the compare function from the string library instead.
http://www.cplusplus.com/reference/string/string/compare.html

char choice;
		string subChoice ="";
		getline(cin,subChoice);

		if(subChoice=="100"){
			choice='1';}
		if(subChoice=="200"){
			choice='2';}
		if(subChoice=="300"){
			choice='3';}
		if(subChoice=="400"){
			choice='4';}
		if(subChoice=="500"){
			choice='5';}
		if(subChoice=="E"){
			choice='E';}

Why did you decide to do so much work??? If the integer they enter is not an 'E' then simply divide by 100 to get the values 1-5.

int choice = menu();
if(choice != 'E')
    choice = choice / 100;

The above is a whole lot less confusing then what you tried to do with all those strings.

I'm really pretty new to programming... I guess I didn't think that out that easily.

Also, wouldn't you have to convert the strings to an integer/double to divide them 100?

I'm pretty sure my teacher won't mind though. I think I'm done with this program for a while. I'm so tired of it now lol.

Thanks for all your help guys. I'll be sure to read up more before having such crazy questions.

For some reason I was having trouble with the switch and 100-500 being strings rather than characters and 'E' being a character rather than a string. I guess a switch cannot have a string as a choice?

EDIT: Not sure how many posts you need for rep to work but I will rep you guys anyways.

I'm really pretty new to programming... I guess I didn't think that out that easily.

Also, wouldn't you have to convert the strings to an integer/double to divide them 100?

I'm pretty sure my teacher won't mind though. I think I'm done with this program for a while. I'm so tired of it now lol.

Thanks for all your help guys. I'll be sure to read up more before having such crazy questions.

For some reason I was having trouble with the switch and 100-500 being strings rather than characters and 'E' being a character rather than a string. I guess a switch cannot have a string as a choice?

EDIT: Not sure how many posts you need for rep to work but I will rep you guys anyways.

I think you need ten posts to get rep power. Just post a bunch of "LOL" posts to get your post count up. Just kidding. Thank you for the rep. It's the thought that counts. Regarding the switch statement on strings, yes, you cannot do a switch on a string. A switch can only be done on what is called an "enumerable" type. A string is not an enumerable type. You CAN, however, handle strings with this type of setup:

if (subChoice.compare ("100") == 0)
{
     // code for choice 100
}
else if (subChoice.compare ("200") == 0)
{
     // code for choice 200
}
else
{
     // code for invalid entry
}

You'd add "else if" blocks for "300", "400", "500", and "E" before the "else" option.

Also, if you want to display the menu each time instead of only once, just move all of those cout lines from BEFORE the while loop to INSIDE the while loop.

why bother with compare() when the == operator is sufficient

if( subchoice == "100")
{

}
else 
if( subchoice == "200")
// blabla

why bother with compare() when the == operator is sufficient

if( subchoice == "100")
{

}
else 
if( subchoice == "200")
// blabla

I'll defer to you on this one Ancient Dragon. I remember way back a teacher telling me not to use == to compare strings and since then I haven't, but now I am beginning to wonder why. Megaz221, ignore my post 8 regarding "compare".

Why bother with strings or char as a type for choice at all. Why not just have the user enter an integer value not used in the menu to exit, say 6 or -1 or 999 or maybe 1234?

Why bother with strings or char as a type for choice at all. Why not just have the user enter an integer value not used in the menu to exit, say 6 or -1 or 999 or maybe 1234?

Good question, and that was suggested before in this thread. For some strange reason the OP decided to use strings.

Actually my teacher specified that I use 'E' to exit and the user has to use 100-500 to order so I don't know. I ended up changing my string comparisons to what Vernon Dozier said in post 8 and she said that was better.

I would have made it that hard if it was up to me but my teacher specified so it doesn't really matter =/

I got an A on the assignment though so I'm pretty psyched about that. I don't plan on missing any more classes though. Thanks for the help guys.

I'll probably have more questions in the future but we'll see when they come. Once again thanks for everyone's input, I think I can learn a lot here.

>>I got an A on the assignment
Great going! :) :)

can u post the finally source code?

commented: And you're getting an F on the assignment -6

>can u post the finally source code?
I guess this is what Dani meant when she said we were getting 1000% more user registrations with a floating popup window.

Thanks many for the help in designing a resturant type style program and the examples listed here. My issue now is developing it to where I can restart the program over. I use C++ 2008 and love it... here is a sameple of the changes I have made... suggestions on figured out how to make it continusiouly run would be helpful..
Inline Code Example Here

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
no

    int tacoQuant=0;
    int enchQuant=0;
    int tamaQuant=0;
    int nachQuant=0;
    int drnkQuant=0;
    double subTotal;
    double tax;
    double totalDue;
    double tacoTotal=0;
    double enchTotal=0;
    double tamaTotal=0;
    double nachTotal=0;
    double drnkTotal=0;

    system("color D");
    cout<<"           Welcome to Daniel's Mexicafeteria!"<<endl;
    cout<<"Please continue to make all your selections by using the item number on the left"<<endl;
    cout<<"When you are finished type 'E' to exit."<<endl;
    cout<<endl;
    cout<<"NOTE: Any selection other than Item# or 'E' will result in a crash"<<endl;
    cout<<endl;
    cout<<"..................................MENU........................................"<<endl;
    cout<<"Item# Description--------------------------------------------------------Price"<<endl;
    cout<<"______________________________________________________________________________"<<endl;
    cout<<"[100] Taco dinner:  2 tacos, rice and beans...............................5.95"<<endl;
    cout<<endl;
    cout<<"[200] Enchilada dinner:  2 cheese enchiladas, rice and beans..............6.95"<<endl;
    cout<<endl;
    cout<<"[300] Tamale dinner:  2 pork tamales, rice and beans......................4.95"<<endl;
    cout<<endl;
    cout<<"[400] Loaded nachos: chips with beef or chicken, cheese and jalapenos.....3.95"<<endl;
    cout<<endl;
    cout<<"[500] DRINKS one-size and free refills......................................95"<<endl;
    cout<<endl;

    bool done = false;
    while(!done)
    {
        char choice;
        string subChoice ="";
        getline(cin,subChoice);

        if(subChoice=="100"){
            choice='1';}
        if(subChoice=="200"){
            choice='2';}
        if(subChoice=="300"){
            choice='3';}
        if(subChoice=="400"){
            choice='4';}
        if(subChoice=="500"){
            choice='5';}
        if(subChoice=="E"){
            choice='E';}

    switch(choice)
    {
    case '1':
        tacoQuant=tacoQuant+1;
        tacoTotal=tacoQuant*5.95;
        break;
    case '2':
    enchQuant=enchQuant+1;
        enchTotal=enchQuant*6.95;
        break;
    case '3':
        tamaQuant=tamaQuant+1;
        tamaTotal=tamaQuant*4.95;
        break;
    case '4':
        nachQuant=nachQuant+1;
        nachTotal=nachQuant*3.95;
        break;
    case '5':
        drnkQuant=drnkQuant+1;
        drnkTotal=drnkQuant*.95;
        break;
    case 'E':
        done = true;
        break;  
    default:
        cout << "invalid choice\n";
        break;

    }
} 

        system("color A");
        cout<<endl;
        cout<<endl;
        cout<<"You have ordered the following:"<<endl;
        cout<<"___________________"<<endl;
        if(tacoQuant!=0){
        cout<<tacoQuant<<"   Taco dinner:  2 tacos, rice and beans                             "<<tacoTotal<<endl;
        }
        if(enchQuant!=0){
            cout<<enchQuant<<"   Enchilada dinner:  2 cheese enchiladas, rice and beans            "<<enchTotal<<endl;
        }
        if(tamaQuant!=0){
            cout<<tamaQuant<<"   Tamale dinner:  2 pork tamales, rice and beans                    "<<tamaTotal<<endl;
        }
        if(nachQuant!=0){
            cout<<nachQuant<<"   Loaded nachos: chips with beef or chicken, cheese and jalapenos   "<<nachTotal<<endl;
        }
        if(drnkQuant!=0){
            cout<<drnkQuant<<"   DRINKS one-size and free refills                                  "<<drnkTotal<<endl;
        }
        cout<<fixed<<setprecision(2)<<endl;
        cout<<"___________________"<<endl;
        subTotal=(tacoTotal+enchTotal+tamaTotal+nachTotal+drnkTotal);
        tax=(subTotal*.075);
        totalDue=(subTotal+tax);
        cout<<"Subtotal     "<<subTotal<<endl;
        cout<<"Tax          "<<tax<<endl;
        cout<<"___________________"<<endl;
        cout<<"Total Due    "<<totalDue<<endl;
        system("PAUSE");
return 0;
}

how to repeat menu of cafe without using any function? plz plz tell me

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.