c++ food menu loop

Write your question here.
Hey I cant figure out where and what type of loop I should put in to get my if statements to activate every time the user inputs y or n please help!
[code]
Put the code you need help with here.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
char choice = 'A';
double salesTax;
const double tax = 0.65;
const double Hotdog = 2.95, Corndog = 3.55, Nachos = 5.25, Tenders = 4.35, Soda = 1.25;
double subtotal = 0;
int answer;
double Total;
int loop = 0;

cout << "Okay Cooking Menu!\n"
<< "(a) An Okay Hotdog $2.95\n"
<< "(b) A Tasty Corndog $4.75\n"
<< "(c) Cheesy Nachos $5.25\n"
<< "(d) Chicken Tenders $4.35\n";



cout << "What would you like?" << endl;
cin >> choice;

cout << "Would you like anything else? y for yes n for no<<endl;
cin >> answer;



if (choice == 'A' || choice == 'a')

{

cout << "\nA: An Okay Hotdog \n" << endl;

subtotal = subtotal + Hotdog;

}

else if (choice == 'B' || choice == 'b')

{

cout << "B: A Tasty Corndog " << endl;

subtotal = subtotal + Corndog;

}

else if (choice == 'C' || choice == 'c')

{

cout << "C: Some cheesy Nachos " << endl;

subtotal = subtotal + Nachos;

}

else if (choice == 'D' || choice == 'd')

{

cout << "D: Good Chicken Tenders " << endl;

subtotal = subtotal + Tenders;

}
subtotal = subtotal;
salesTax = subtotal * tax;
Total = subtotal + salesTax;

cout << "Your Total before Tax is: " << subtotal << " " <<endl;
cout << "The Tax is: " << salesTax << " " << endl;
cout << "Your total is: " << " " << Total << endl;

return 0;
}
what you are looking for is a while loop

1) print the Menu
2) get input from the user
3) check if conditions
4) ask the user if he wants to quit or order again
5) get that input

here is some pseudo code,showing what steps need to be taken.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

bool quit = false;

while(!quit){

 // 1) print the Menu
 //2) get input from the user
 //3) check if conditions
 //4) ask the user if he wants to quit or order again
 //5) get input
  
   if(yes){
      
       quit = true;// quit now equals true
   }
 
}

Last edited on
Topic archived. No new replies allowed.