How can i loop this back to the start. at the end of code of change the program will ask if user want to order again. And if he answer Y then it will loop back, starting from the first code and switch statement and if it answer N the program will end. (There should be 4 case but i didn't include the 3 so the code will not be too long, just imagine theres 3 more)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
How can i loop this back to the start. at the end of code of change the program will ask if user want to order again. And if he answer Y then it will loop back, starting from the first code and switch statement and if it answer N the program will end. (There should be 4 case but i didn't include the 3 so the code will not be too long, just imagine theres 3 more)
#include <iostream>
using namespace std;
int main()
{
char ordrnum ,loop;
int sum = 0, sum2=0,q1=0, q2=0 , q3=0,q4=0,payment ;
cout << "Good day, Lodi. What's your order?\n "
endl;
cout << "Press 1 for Dishes" << endl;
cout << "Press 2 for Drinks" << endl;
cout << "Press 3 for Dessert" << endl;
cout << "Press 4 for Burgers" << endl;
くく
cout
---\n";
cout << "Enter your order: -\n";
cin >> ordrnum;
switch (ordrnum) {
case '1':
char tinola, menudo,curry, adobo;
cout << "Dishes\n";
cout << "[1] Tinola - 35"<<endl:
cout << "[2] Menudo 30"<<endl;
cout << "[3] Chicken Curry - 40"<<endl;
cout << "[4] Adobo - 45"<<endl;
cout <<
-\n";
//Selecting
cout<<"Select Your Dishes "<<endl;
cout << "[1] Tinola [Y/N] : ";
cin >> tinola;
if (tinola == 'Y') {
cout << "Quantity: ";
cin >> q1;
}
cout << "[2] Menudo [Y/N] : ";
cin>>menudo;
if (menudo == 'Y') {
cout << "Quantity: ";
cin >> q2;
}
cout << "[3] Chicken Curry [Y/N] : ";
cin>>curry;
if (curry == 'Y') {
cout << "Quantity: ";
cin >> q3;
Transcribed Image Text:#include <iostream> using namespace std; int main() { char ordrnum ,loop; int sum = 0, sum2=0,q1=0, q2=0 , q3=0,q4=0,payment ; cout << "Good day, Lodi. What's your order?\n " endl; cout << "Press 1 for Dishes" << endl; cout << "Press 2 for Drinks" << endl; cout << "Press 3 for Dessert" << endl; cout << "Press 4 for Burgers" << endl; くく cout ---\n"; cout << "Enter your order: -\n"; cin >> ordrnum; switch (ordrnum) { case '1': char tinola, menudo,curry, adobo; cout << "Dishes\n"; cout << "[1] Tinola - 35"<<endl: cout << "[2] Menudo 30"<<endl; cout << "[3] Chicken Curry - 40"<<endl; cout << "[4] Adobo - 45"<<endl; cout << -\n"; //Selecting cout<<"Select Your Dishes "<<endl; cout << "[1] Tinola [Y/N] : "; cin >> tinola; if (tinola == 'Y') { cout << "Quantity: "; cin >> q1; } cout << "[2] Menudo [Y/N] : "; cin>>menudo; if (menudo == 'Y') { cout << "Quantity: "; cin >> q2; } cout << "[3] Chicken Curry [Y/N] : "; cin>>curry; if (curry == 'Y') { cout << "Quantity: "; cin >> q3;
cout << "[4] Adobo [Y/N] : ";
cin>>adobo;
if (adobo == 'Y') {
cout << "Quantity: ";
cin >> q4;
}
//printing dish selected along with price
cout<<"\nDish
"<<endl;
\t\t Price
if(menudo =='Y'){
cout<<"Tinola
\t\t 35 "
<< "*" <<
q1<<endl;
sum=sum+35;
sum=sum*q1;
}
if(menudo =='Y'){
cout<<"Menudo
\t\t 30 "<< "*"
<<
q2<<end1; ;
sum=sum+30*q2;
}
if(curry =='Y'){
cout<<"Chicken Curry \t\t 40 "
<< "*" <<
q3<<endl;
sum=sum+40*q3;
}
if(adobo =='Y'){
cout<<"Adobo
\t\t 45 " << "*" <<
q4<<endl;
sum=sum+45*q4;
}
//printing total price
cout <<"-
"B
cout<<"\nTotal Price
cout << "Payment: ";
cin >> payment;
\t\t" << sum << endl;
sum2 = payment - sum;
if (sum2 > 0) {
cout << "Your change is:" < sum2 << endl;
}
else {
cout << "You still have "
<< sum2 << "
balance to pay" << endl;
cout << "Do you want to order again?
[Y/N]";
cin >> loop;
break;
}
return 0;
}
Transcribed Image Text:cout << "[4] Adobo [Y/N] : "; cin>>adobo; if (adobo == 'Y') { cout << "Quantity: "; cin >> q4; } //printing dish selected along with price cout<<"\nDish "<<endl; \t\t Price if(menudo =='Y'){ cout<<"Tinola \t\t 35 " << "*" << q1<<endl; sum=sum+35; sum=sum*q1; } if(menudo =='Y'){ cout<<"Menudo \t\t 30 "<< "*" << q2<<end1; ; sum=sum+30*q2; } if(curry =='Y'){ cout<<"Chicken Curry \t\t 40 " << "*" << q3<<endl; sum=sum+40*q3; } if(adobo =='Y'){ cout<<"Adobo \t\t 45 " << "*" << q4<<endl; sum=sum+45*q4; } //printing total price cout <<"- "B cout<<"\nTotal Price cout << "Payment: "; cin >> payment; \t\t" << sum << endl; sum2 = payment - sum; if (sum2 > 0) { cout << "Your change is:" < sum2 << endl; } else { cout << "You still have " << sum2 << " balance to pay" << endl; cout << "Do you want to order again? [Y/N]"; cin >> loop; break; } return 0; }
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY