The code snippet below is part of the restaurant menu program you previously used in the lab. Add a choice for a drink. Add the necessary code to allow the program to calculate the total price of order for the user. Assume the following price list: Hamburger $5 Hotdog $4 Fries $3 Drink $2 The program should allow the user to keep entering order until choosing to exit. At the end the program prints an order summary like this: You ordered 2 hamburger(s), 1 hotdog(s), 3 fries, 0 drink(s). Price: $23 HST: $2.99 Total: $25.99
do { printf("What do you want to eat today?\n"); printf("1. Hamburger\n"); printf("2. Hotdog\n"); printf("3. Fries\n"); printf("4. Exit\n"); printf("Enter your choice: "); scanf("%d", &choice); switch(choice){ case 1: printf("You ordered a hamburger\n"); break; case 2: printf("You ordered a hotdog\n"); break; case 3: printf("You ordered fries\n"); break; case 4: printf("Order finished, thank you!\n"); break; default: printf("Wrong choice! try again: "); } } while (choice != 4);
Explanation::
Code in C::
#include<stdio.h>
int main(){
int choice;
int hamburger=0,hotdog=0,fries=0,drink=0,exit=0;
do {
printf("What do you want to eat today?\n");
printf("1. Hamburger\n");
printf("2. Hotdog\n");
printf("3. Fries\n");
printf("4. Drinks\n");
printf("5. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch(choice){
case 1:
printf("You ordered a hamburger\n");
hamburger++;
break;
case 2:
printf("You ordered a hotdog\n");
hotdog++;
break;
case 3:
printf("You ordered fries\n");
fries++;
break;
case 4:
printf("You ordered drinks\n");
drink++;
break;
case 5:
printf("Order finished, thank you!\n");
break;
default:
printf("Wrong choice! try again: ");
break;
}
} while (choice != 5);
int total=hamburger*5+hotdog*4+fries*3+drink*2;
float tax=0.13*total;
float grandTotal=total+tax;
printf("You ordered %d hamburger(s), %d hotdog(s), %d fries, %d
drink(s). Price: $%d HST: $%.2f Total:
$%.2f",hamburger,hotdog,fries,drink,total,tax,grandTotal);
return 0;
}
OUTPUT::
What do you want to eat today?
1. Hamburger
2. Hotdog
3. Fries
4. Drinks
5. Exit
Enter your choice: 1
You ordered a hamburger
What do you want to eat today?
1. Hamburger
2. Hotdog
3. Fries
4. Drinks
5. Exit
Enter your choice: 1
You ordered a hamburger
What do you want to eat today?
1. Hamburger
2. Hotdog
3. Fries
4. Drinks
5. Exit
Enter your choice: 2
You ordered a hotdog
What do you want to eat today?
1. Hamburger
2. Hotdog
3. Fries
4. Drinks
5. Exit
Enter your choice: 3
You ordered fries
What do you want to eat today?
1. Hamburger
2. Hotdog
3. Fries
4. Drinks
5. Exit
Enter your choice: 3
You ordered fries
What do you want to eat today?
1. Hamburger
2. Hotdog
3. Fries
4. Drinks
5. Exit
Enter your choice: 3
You ordered fries
What do you want to eat today?
1. Hamburger
2. Hotdog
3. Fries
4. Drinks
5. Exit
Enter your choice: 5
Order finished, thank you!
You ordered 2 hamburger(s), 1 hotdog(s), 3 fries, 0 drink(s).
Price: $23 HST: $2.99 Total: $25.99
Process returned 0 (0x0) execution time : 22.982 s
Press any key to continue.
Please provide the feedback!!
Thank You!!
The code snippet below is part of the restaurant menu program you previously used in the...
Using C++ Mr. Manager wants you to process orders for the Fast Greasy Food Shop. His customers have a few choices in what they order. The can order a hamburger for 1.00. It they want cheese it is an addition .50 and if they want bacon the additional amount is .75. They can also order a small or large drink for 1.10 and 1.60 respectively and small or large French fries for 1.20 or 1.75 respectively. The user can only...
C LANGUAGE. PLEASE INCLUDE COMMENTS :)
>>>>TheCafe V2.c<<<<
#include <stdio.h>
int main()
{
int fries; // A flag denoting whether they want fries or not.
char bacon; // A character for storing their bacon preference.
double cost = 0.0; // The total cost of their meal, initialized to start at 0.0
int choice; // A variable new to version 2, choice is an int that will store the
// user's menu choice. It will also serve as our loop control...
create case 4 do Method 1:copy item by item and skip the item you want to delete after you are done, delete the old file and rename the new one to the old name. #include int main(void) { int counter; int choice; FILE *fp; char item[100]; while(1) { printf("Welcome to my shopping list\n\n"); printf("Main Menu:\n"); printf("1. Add to list\n"); printf("2. Print List\n"); printf("3. Delete List\n"); printf("4. Remove an item from the List\n"); printf("5. Exit\n\n"); scanf("%i", &choice); switch(choice) { case 1:...
PLEASE ADD PRICE CHECK IN MY CODE BELOW: ADD THIS: Price check Prompt the user to input the SKU number for the item they are looking for. Search through the inventory and display the cost of the item. Note that if the item does not exist in the inventory, the program displays an informative message. MY CODE: #include <stdio.h> #include <stdlib.h> // define maximum number of items const MAX_ITEMS = 10; //struct to use as asked in problem struct Item{...
Write a C program that does the following: Displays a menu (similar to what you see in a Bank ATM machine) that prompts the user to enter a single character S or D or Q and then prints a shape of Square,Diamond (with selected height and selected symbol), or Quits if user entered Q.Apart from these 2 other shapes, add a new shape of your choice for any related character. Program then prompts the user to enter a number and...
Below is a snippet of code that relies on three methods: execA, execB, and execC. The worst, best, and average time complexity is given for each of these functions. int exec = random.nextInt(6); switch(exec) { case 0: execA(n); // O(n4), Omega(log n), Theta(n) break; case 5: execB(n); // O(n4), Omega(n), Theta(n) break; default: execC(n); // O(n3), Omega(n2), Theta(n*log n) } Please answer the following: 1. [2 marks] What is the worst case Big-O for this code? Justify your answer. 2....
Using the code snippet below, complete the missing sections using the comments as a guide ******************************************************************************** #include <stdio.h> #include <stdlib.h> // The four arithmetic operations ... one of these functions is selected // at runtime with a switch or a function pointer float Plus (float a, float b) { return a+b; } float Minus (float a, float b) { return a-b; } float Multiply(float a, float b) { return a*b; } float Divide (float a, float b) { return a/b;...
C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the class program with methods and variables 2. bill.cpp = contains the functions from class file 3. main.cpp = contains the main program. Please split this program into three files and make the program run. I have posted the code here. #include<iostream>...
C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. I am using printf and scanf. Instead of printf and scanf use cin and cout to make the program run. after this please split this program in three files 1. bill.h = contains the class program with methods and variables eg of class file class bill { } 2. bill.cpp = contains the functions from class...
At this time, you need to create menu driven program. The menu includes the following list. The menu should keep showing if a wrong choice is selected until one of the choices of 1 to 4 is selected. After each of the options 1 to 3 is done, the program shows the menu and waits for the user's choice. Upload your code here. 1. Add odd numbers from a to b 2. Add even numbers from a to b 3....