Hello, I need help with this code. I have screenshots of the problem and some st
ID: 3739859 • Letter: H
Question
Hello, I need help with this code. I have screenshots of the problem and some stuff to help you do it the way it's required. I already wrote some of the code but I'm stuck, especially on the idiot-proofing and calculation part. The code is in basic C, not C++ or C#.
You've just opened an Italian restaurant Each meal your restaurant serves can consist of an entree, a dessert, and a drink. Your Italian restaurant serves several entrees (cheese ravioli, beef rigatoni, vegetarian lasagna), several desserts (cheesecake, tiramisu, gelato), and several drinks (coffee, soda, tea) Your restaurant also has a kiddie menu for children, with two additional entrees (spaghetti, maca- roni and cheese), and one additional drink (lemonade) Each entree has two size options: small and large. (Desserts and drinks come in one size only.) Each entree price depends on the size choice: for each, the small size is cheaper than the large size. Children can order either from the regular menu or from the kiddie menu, but they can only order the small size of the adult entrees, or one of the kiddie entrees (which only come in one size) Children CANNOT order coffee or tea. Adults CANNOT order the kiddie entrees or the kiddie drinks A customer can order AT MOST one item from each category; for example, they can order a large vegetarian lasagna as their entree, cheesecake as their dessert and coffee as their drink. But, they AREN'T REQUIRED to order one of each category; for example, they can order no entree or dessert at all, just a cup of coffee The prices are Item Price SmallLarge |Item Price Price $7.25 $9.00 Cheesecake $4.25 $8.75 $10.50 Tiramisu S5.50 Cheese Ravioli Beef Rigatoni Vegetarian Lasagna $9.50 $11.25 Gelato Spaghetti Macaroni & Cheese $3.7:5 $3.75 $2.75 $1.50 $2.00 $4.50 Coffee Soda Tea Lemonade $1.75 Your community's sales tax rate is 8.75%. A tip of 18% is automatically added to every bill NOTE: You are welcome to substitute other items, as long as you do so consistently and continue to follow the rules. For example, you could change beef rigatoni to eggplant parmigiana, etc, but the number and categories of items, and the prices, MUST remain the sameExplanation / Answer
ScreenShot
----------------------------------------------------------------------------------------
Code
//Header File
#include <stdio.h>
#include<stdlib.h>
//Calculation subsection
void calculateBill(int age,int entree,int eSize,int desert,int drink){
float subtotal=0,total;
if(age==1){
if(entree!=0 && desert!=0){
if(eSize==1 && entree==1 && desert==1 && drink==1){
total+=7.25+4.25+2.75;
}
else if(eSize==1 && entree==1 && desert==2 && drink==1){
total+=7.25+5.50+2.75;
}
else if(eSize==1 && entree==1 && desert==3 && drink==1){
total+=7.25+3.75+2.75;
}
else if(eSize==1 && entree==1 && desert==3 && drink==2){
total+=7.25+3.75+2;
}
else if(eSize==1 && entree==1 && desert==3 && drink==3){
total+=7.25+3.75+1.50;
}
else if(eSize==1 && entree==1 && desert==2 && drink==2){
total+=7.25+5.50+2;
}
else if(eSize==1 && entree==1 && desert==2 && drink==3){
total+=7.25+5.50+1.50;
}
else if(eSize==1 && entree==1 && desert==1 && drink==2){
total+=7.25+4.25+2;
}
else if(eSize==1 && entree==1 && desert==1 && drink==3){
total+=7.25+4.25+1.50;
}
else if(eSize==1 && entree==2 && desert==1 && drink==1){
total+=8.75+4.25+2.75;
}
else if(eSize==1 && entree==2 && desert==1 && drink==2){
total+=8.75+4.25+2;
}
else if(eSize==1 && entree==2 && desert==1 && drink==3){
total+=8.75+4.25+1.50;
}
else if(eSize==1 && entree==2 && desert==2 && drink==1){
total+=8.75+5.50+2.75;
}
else if(eSize==1 && entree==2 && desert==2 && drink==2){
total+=8.75+5.50+2;
}
else if(eSize==1 && entree==2 && desert==2 && drink==3){
total+=8.75+5.50+1.50;
}
else if(eSize==1 && entree==2 && desert==3 && drink==1){
total+=9.50+3.75+2.75;
}
else if(eSize==1 && entree==2 && desert==3 && drink==2){
total+=9.50+3.75+2;
}
else if(eSize==1 && entree==2 && desert==3 && drink==3){
total+=9.50+3.75+1.50;
}
}
}
//Display section
if(entree==1 && eSize==1 && desert==1 && drink==1 ){
printf(" Small Cheese Ravoli $7.25 ");
printf(" CheeseCake $4.25 ");
printf(" Coffee $2.75 ");
printf("------------------------------------------ ");
printf(" SubTotal $%.2f ",(total*100.0)/100 );
printf(" Tax $%.2f ",((total*.0875)*100.0)/100 );
printf(" Tip $%.2f ",((total*.18)*100.0)/100 );
printf("-------------------------------------------- ");
printf(" GrandTotal $%.2f ",((total*.0875+(total*.18 )+(total))*100.0)/100);
}
}
//Main Section
int main()
{
//User prompt section
int cat,ent,entS,des,dr;
//Greet customer
printf ( "--------------------------------------------------------------- ");
printf ( " Welcome To Enrico's Bistro ");
printf ( "--------------------------------------------------------------- ");
/*Customer prompt*/
printf ( " Which age category are you ? ") ;
printf ( " Please Enter: ");
printf ( " 1 For Adult ") ;
printf ( " 2 For childt ") ;
scanf ("%d",&cat);
if (cat == 1) {
printf( " What entree item would you like ? " );
printf( " Please Enter: ");
printf( " 0 For No entree ");
printf( " 1 For Cheese Ravioli " );
printf( " 2 For Beef Rigatoni ");
printf( " 3 For Vegeterian Lasanga ");
scanf("%d",&ent);
printf( " What entree size would you like ? ");
printf( " Please Enter: ");
printf( " 1 For Small ");
printf( " 2 For Large ");
scanf("%d",&entS);
printf( " What desert item would you like ? ");
printf( " Please Enter: ");
printf( " 0 For No desert ");
printf( " 1 For CheeseCake ");
printf( " 2 For Tiramisu ");
printf( " 3 For Gelato ");
scanf("%d",&des);
printf( " What drinkt item would you like ? ");
printf( " Please Enter: ");
printf( " 1 For Coffee ");
printf( " 1 For Tea ");
printf( " 2 For Soda ");
scanf("%d",&dr);
}
else if (cat == 2) {
printf( " What entree item would you like ? ");
printf( " Please Enter: ");
printf( " 0 For No entree ");
printf( " 1 For Cheese Ravioli ");
printf( " 2 For Beef Rigatoni ");
printf( " 3 For Vegeterian Lasanga ");
printf( " 4 For Spagetti ");
printf( " 5 For Macroni and Cheese ");
scanf("%d",&ent);
printf( " What desert item would you like ? ");
printf( " Please Enter: ");
printf( " 0 For No desert ");
printf( " 1 For CheeseCake ");
printf( " 2 For Tiramisu ");
printf( " 3 For Gelato ");
scanf("%d",&des);
printf( " What drinkt item would you like ? ");
printf( " Please Enter: ");
printf( " 1 Lemonade ");
printf( " 2 For Soda ");
scanf("%d",&dr);
}
//Output display section
//Bill
printf ( "--------------------------------------------------------------- ");
printf ( " Enrico's Bistro Bill ");
printf ( "--------------------------------------------------------------- ");
calculateBill(cat,ent,entS,des,dr);
printf ( " Thank you visiting Enrico!!! ");
printf ( "--------------------------------------------------------------- ");
return 0;
}
-------------------------------------------------------------------------------------------------------
Output
------------------------------------------------------------------------------------------------------------------------------
Note:-
This is a large project,we have time constraints,So i did the overall part not complete.
I assume ,this will give you the basic idea.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.