EXPLAIN THIS CODE EACH LINE #include #include int main() { char name[20]; int meal,quantity; int drink,quantity2; char choose_meal[30] = ""; int meal_price; float drink_price, orderPrice; char choose_drink[30] = ""; float cash, change; printf("--------------------Marry's Fast Food--------------------"); printf("\n"); printf("Enter your name: "); scanf("%s", name); printf("Hello %s!\n", name); printf("\n\nWhat would you like to order?\n"); printf("------------------------MEALS------------------------\n\n"); printf("[1] 1 pc. Chicken Joy....................Php 76.00\n"); printf("[2] 1 pc. w/Jolly spaghetti..............Php 99.00\n"); printf("[3] pc. Spaghetti........................Php 55.00\n"); printf("[4] pc. Burger steak w/rice..............Php 85.00\n"); printf("[5] pc. Burger...........................Php 30.00\n\n"); printf("Choose a number for your meal: "); scanf("%d", &meal); printf("Quantity: "); scanf("%d", &quantity); printf("-----------------------DRINKS-----------------------\n\n"); printf("[1] Coke.................................Php 15.20\n"); printf("[2] Sprite...............................Php 15.25\n"); printf("[3] Royal................................Php 15.30\n"); printf("[4] Pineapple............................Php 20.25\n"); printf("[5] Iced Tea.............................Php 20.25\n\n"); printf("Choose a number for your drink: "); scanf("%d", &drink); printf("Quantity: "); scanf("%d", &quantity2); if(meal==1){ strcpy(choose_meal,"Chicken Joy"); meal_price = 76; } else if(meal==2){ strcpy(choose_meal,"w/Jolly spaghetti"); meal_price = 99; } else if(meal==3){ strcpy(choose_meal,"Spaghetti"); meal_price = 55; } else if(meal==4){ strcpy(choose_meal,"Burger steak w/rice"); meal_price = 85; } else{ strcpy(choose_meal, "Burger"); meal_price = 30; } if(drink==1){ strcpy(choose_drink, "Coke"); drink_price = 15.20; } else if(drink==2){ strcpy(choose_drink,"Sprite"); drink_price = 15.25; } else if(drink==3){ strcpy(choose_drink, "Royal"); drink_price = 15.30; } else if(drink==4){ strcpy(choose_drink, "Pineapple"); drink_price = 20.50; } else{ strcpy(choose_drink, "Iced Tea"); drink_price = 20.75; } printf("---------------------ITEM ORDERED---------------------\n\n"); printf("%s.....................Php %d x %d = %d",choose_meal,meal_price,quantity,meal_price*quantity); printf("\n"); printf("%s.....................Php %f x %d = %f",choose_drink,drink_price,quantity2,drink_price*quantity2); orderPrice = meal_price*quantity+drink_price*quantity2; printf("\n"); printf("Total amount is %f",orderPrice ); printf("\nCash: " ); scanf("%f", &cash); if (orderPrice <= cash ) { printf("Change: %f", cash-meal_price*quantity+drink_price*quantity2); printf("\n\n"); printf("---------------------------------------------------\n\n"); printf(" THANK YOU ENJOY THE MEAL! \n\n"); printf("---------------------------------------------------\n"); scanf("%f", &change); } else { printf("Please give enough money."); } return 0; }
EXPLAIN THIS CODE EACH LINE
#include <stdio.h>
#include<string.h>
int main()
{
char name[20];
int meal,quantity;
int drink,quantity2;
char choose_meal[30] = "";
int meal_price;
float drink_price, orderPrice;
char choose_drink[30] = "";
float cash, change;
printf("--------------------Marry's Fast Food--------------------");
printf("\n");
printf("Enter your name: ");
scanf("%s", name);
printf("Hello %s!\n", name);
printf("\n\nWhat would you like to order?\n");
printf("------------------------MEALS------------------------\n\n");
printf("[1] 1 pc. Chicken Joy....................Php 76.00\n");
printf("[2] 1 pc. w/Jolly spaghetti..............Php 99.00\n");
printf("[3] pc. Spaghetti........................Php 55.00\n");
printf("[4] pc. Burger steak w/rice..............Php 85.00\n");
printf("[5] pc. Burger...........................Php 30.00\n\n");
printf("Choose a number for your meal: ");
scanf("%d", &meal);
printf("Quantity: ");
scanf("%d", &quantity);
printf("-----------------------DRINKS-----------------------\n\n");
printf("[1] Coke.................................Php 15.20\n");
printf("[2] Sprite...............................Php 15.25\n");
printf("[3] Royal................................Php 15.30\n");
printf("[4] Pineapple............................Php 20.25\n");
printf("[5] Iced Tea.............................Php 20.25\n\n");
printf("Choose a number for your drink: ");
scanf("%d", &drink);
printf("Quantity: ");
scanf("%d", &quantity2);
if(meal==1){
strcpy(choose_meal,"Chicken Joy");
meal_price = 76;
}
else if(meal==2){
strcpy(choose_meal,"w/Jolly spaghetti");
meal_price = 99;
}
else if(meal==3){
strcpy(choose_meal,"Spaghetti");
meal_price = 55;
}
else if(meal==4){
strcpy(choose_meal,"Burger steak w/rice");
meal_price = 85;
}
else{
strcpy(choose_meal, "Burger");
meal_price = 30;
}
if(drink==1){
strcpy(choose_drink, "Coke");
drink_price = 15.20;
}
else if(drink==2){
strcpy(choose_drink,"Sprite");
drink_price = 15.25;
}
else if(drink==3){
strcpy(choose_drink, "Royal");
drink_price = 15.30;
}
else if(drink==4){
strcpy(choose_drink, "Pineapple");
drink_price = 20.50;
}
else{
strcpy(choose_drink, "Iced Tea");
drink_price = 20.75;
}
printf("---------------------ITEM ORDERED---------------------\n\n");
printf("%s.....................Php %d x %d = %d",choose_meal,meal_price,quantity,meal_price*quantity);
printf("\n");
printf("%s.....................Php %f x %d = %f",choose_drink,drink_price,quantity2,drink_price*quantity2);
orderPrice = meal_price*quantity+drink_price*quantity2;
printf("\n");
printf("Total amount is %f",orderPrice );
printf("\nCash: " );
scanf("%f", &cash);
if (orderPrice <= cash )
{
printf("Change: %f", cash-meal_price*quantity+drink_price*quantity2);
printf("\n\n");
printf("---------------------------------------------------\n\n");
printf(" THANK YOU ENJOY THE MEAL! \n\n");
printf("---------------------------------------------------\n");
scanf("%f", &change);
}
else
{
printf("Please give enough money.");
}
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images