Please Help....This program only calculate bill for one burger ...how do i do this for multiple burgers?

QUESTION:Write a C++ code to develop a software for your burger shop that takes orders for a tasty burger
from the user, in just 5 steps. Attached below is the menu that you are going to display to the
user in a nice attractive format.
First of all you will ask the user to enter the number of burgers he wants to order. Foreach burger
the user can only add one type of bun to the burger. Any number of cheeses, 1 item from the
category “turn up the taste”, maximum 3 from fresh’n it up and any number of sauces. If the user
presses 0 then you are going to skip that category (user can not skip “choose your bun” and “turn
up the taste”).



My Code:


#include<iostream>
using namespace std;
int main()
{
int burgers,bun,cheese,bill,taste,fresh=0,sauce,i=0;
float bunprice,cheeseprice,tasteprice,freshprice,sauceprice,j=1,k=1,l=1,totalcost;
cout<<"Welcome To The Burger Shop!\n";

cout<<"Enter The Amount Of Burgers You Want:\n";
cin>>burgers;


cout<<"Choose Your Bun:\n1.Toasted Brioche Style Bun\n2.Baker's Bun\n3.No Bun-Lettuce Wrap\n";
cin>>bun;
bunprice=bun*0.5;
cout<<"Make It Cheesy:\n";
cout<<"1.Cheddar Cheese\n2.Swiss Cheese\n3.Colby Jack Cheese\n4.McDonald's Classic Cheese\n5.Shaved Parmesan\n0.To Skip Or Stop\n";
do
{
cin>>cheese;
if(cheese==1 ||cheese==2 || cheese==3 || cheese==4 || cheese==5)
cheeseprice=l*0.5;
l++;
}while(cheese!=0);

cout<<"Turn Up The Taste:\n1.Rasher Bacon\n2.Crispy Bacon\n3.Egg\n4.Angus Beef Patty\n5.Guacamole\n6.Tortilla Strips\n7.Grilled Mushrooms\n8.Grilled Pineapple\n";
cin>>taste;
tasteprice=taste*1.2;


cout<<"Fresh'N It Up\n";
cout<<"1.Whole Leaf Lettuce\n2.Tomato\n3.Caramelised Grilled Onions\n4.Sliced Beetroot\n5.Red Onion\n6.Long Sliced Pickle\n7.Jalaperos\n";

do
{
cin>>fresh;
if(fresh==1 || fresh==2 || fresh==3 || fresh==4 || fresh==5 || fresh==6 || fresh==7){
freshprice=k*0.2;}
k++;
i++;
}while(i<3);



cout<<"Get Saucy:\n1.Ketchup 2.Tomato Chilli Jam\n3.BBQ 4.Dijonnaise\n5.Big Mac Special Sauce 6.Aioli\n7.Herb Aioli 8.Chipotle Mayo\n";
do
{
cin>>sauce;
if (sauce==1 || sauce==2|| sauce==3|| sauce==4|| sauce==5|| sauce==6|| sauce==7){
sauceprice = j*0.3;}
j++;
}while(sauce!=0);

totalcost= sauceprice+freshprice+cheeseprice+bunprice+tasteprice;
cout<<"Total Cost Of Your Burger Is:"<<totalcost<<endl;





}



Last edited on
Speaking of nice attractive format, apply this -> https://www.cplusplus.com/articles/jEywvCM9/
Spot the difference

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
using namespace std;

int main()
{
	int burgers, bun, cheese, bill, taste, fresh = 0, sauce, i = 0;
	float bunprice, cheeseprice, tasteprice, freshprice, sauceprice, j = 1, k = 1, l = 1, totalcost;

	cout << "Welcome To The Burger Shop!\n";
	cout << "Enter The Amount Of Burgers You Want:\n";
	cin >> burgers;

	cout << "Choose Your Bun:\n1.Toasted Brioche Style Bun\n2.Baker's Bun\n3.No Bun-Lettuce Wrap\n";
	cin >> bun;

	bunprice = bun * 0.5;

	cout << "Make It Cheesy:\n";
	cout << "1.Cheddar Cheese\n2.Swiss Cheese\n3.Colby Jack Cheese\n4.McDonald's Classic Cheese\n5.Shaved Parmesan\n0.To Skip Or Stop\n";
	do {
		cin >> cheese;

		if (cheese == 1 || cheese == 2 || cheese == 3 || cheese == 4 || cheese == 5)
			cheeseprice = l * 0.5;

		l++;
	} while (cheese != 0);

	cout << "Turn Up The Taste:\n1.Rasher Bacon\n2.Crispy Bacon\n3.Egg\n4.Angus Beef Patty\n5.Guacamole\n6.Tortilla Strips\n7.Grilled Mushrooms\n8.Grilled Pineapple\n";
	cin >> taste;

	tasteprice = taste * 1.2;

	cout << "Fresh'N It Up\n";
	cout << "1.Whole Leaf Lettuce\n2.Tomato\n3.Caramelised Grilled Onions\n4.Sliced Beetroot\n5.Red Onion\n6.Long Sliced Pickle\n7.Jalaperos\n";

	do {
		cin >> fresh;

		if (fresh == 1 || fresh == 2 || fresh == 3 || fresh == 4 || fresh == 5 || fresh == 6 || fresh == 7)
			freshprice = k * 0.2;

		k++;
		i++;
	} while (i < 3);

	cout << "Get Saucy:\n1.Ketchup 2.Tomato Chilli Jam\n3.BBQ 4.Dijonnaise\n5.Big Mac Special Sauce 6.Aioli\n7.Herb Aioli 8.Chipotle Mayo\n";

	do {
		cin >> sauce;

		if (sauce == 1 || sauce == 2 || sauce == 3 || sauce == 4 || sauce == 5 || sauce == 6 || sauce == 7)
			sauceprice = j * 0.3;

		j++;
	} while (sauce != 0);

	totalcost = sauceprice + freshprice + cheeseprice + bunprice + tasteprice;
	cout << "Total Cost Of Your Burger Is:" << totalcost << endl;
}


This program only calculate bill for one burger ...how do i do this for multiple burgers?


Put another do-loop around the code. At the end of the above ask if another burger wanted. get a response and loop if the response is they do.
Last edited on
Ok ThankYou <3
Topic archived. No new replies allowed.