I have a problem with this code can please fix it and explain it for me: //header files #include #include #include //main body int main() { std::string pizza_type; char size; std::cout<<"Welcome to Freddy's Pizza\n\n"; std::cout<<"Pizza Menu:\n"; std::cout<<"\t1- Vegetarian Pizza\n"; std::cout<<"\t2- Chicken Dynamite Pizza\n"; std::cout<<"\t3- Vegetarian Lovers Pizza\n";
I have a problem with this code can please fix it and explain it for me:
//header files
#include<iostream>
#include<conio.h>
#include<string.h>
//main body
int main()
{
std::string pizza_type;
char size;
std::cout<<"Welcome to Freddy's Pizza\n\n";
std::cout<<"Pizza Menu:\n";
std::cout<<"\t1- Vegetarian Pizza\n";
std::cout<<"\t2- Chicken Dynamite Pizza\n";
std::cout<<"\t3- Vegetarian Lovers Pizza\n";
std::cout<<"\nWhich Pizza would you like to try?\t";
getline(std::cin,pizza_type);
std::cout<<"\nWhat size of pizza would you like (L,M,S)?\t\t";
std::cin>>size;
if(size=='L'||size=='M'||size=='S') //checking the selection order of pizza size
{
if(strcmp(pizza_type.c_str(),"Vegetarian")==0) //chceking the selection order of pizza type
{ std::cout<<"\n\nPizza Order:\n";
std::cout<<"\nPizza Name:"<<pizza_type;
std::cout<<"\nPreparation Time:20 Minutes\n";
std::cout<<"\nCalories:25\n";
if(size=='L')
std::cout<<"\nPizza Price:4 OMR\n";
else if(size=='M')
std::cout<<"\nPizza Price:3 OMR\n";
else
std::cout<<"\nPizza Price:2 OMR\n";
std::cout<<"\nToppings:\n";
std::cout<<"\nOnion,Green paper,Olives,Sweet Corn and Mushrooms";
}
else if(strcmp(pizza_type.c_str(),"Chicken Dynamite")==0) //chceking the selection order of pizza type
{
std::cout<<"\n\nPizza Order:\n";
std::cout<<"\nPizza Name:"<<pizza_type;
std::cout<<"\nPreparation Time:20 Minutes\n";
std::cout<<"\nCalories:150\n";
if(size=='L')
std::cout<<"\nPizza Price:7 OMR\n";
else if(size=='M')
std::cout<<"\nPizza Price:5 OMR\n";
else
std::cout<<"\nPizza Price:3 OMR\n";
std::cout<<"\nToppings:\n";
std::cout<<"\nGrilled Chicken,Cheese,Raunch Sauce,Jalapenos";
}
else if(strcmp(pizza_type.c_str(),"Meat Lovers")==0) //chceking the selection order of pizza type
{ std::cout<<"\n\nPizza Order:\n";
std::cout<<"\nPizza Name:"<<pizza_type;
std::cout<<"\nPreparation Time:20 Minutes\n";
std::cout<<"\nCalories:250\n";
if(size=='L')
std::cout<<"\nPizza Price:8 OMR\n";
else if(size=='M')
std::cout<<"\nPizza Price:6 OMR\n";
else
std::cout<<"\nPizza Price:4 OMR\n";
std::cout<<"\nToppings:\n";
std::cout<<"\nMinced Meat,Cheese,BBQ Sauce,Fresh Tomatos";
}
else //if the selection order is wrong
std::cout<<"wrong selection";
}
else //if the selection order is wrong
std::cout<<"wrong selection";
getch();
return 0;
}
Step by step
Solved in 2 steps with 1 images