Assume you work as a cashier in a restaurant. You must keep track of the amount of money your restaurant earns each day and report it to your boss. If a customer purchases something, that amount is added to the daily income book. Take a customer's order and if a customer enters an "X," the order is complete, and print "Total cost of the items: ". In this way, 3 customers can order at maximum as your restaurant only serves three customers per day; after the service, print the day's total income; if the total money exceeds 500tk, print "Great Work". Otherwise, print "Do Best Next Day." Note: Write a function called “take_order()” that asks users to input food names, calculate the amount and show it to the customer. When the last customer buys, you need to also calculate the total income of the day and show it at the end. Assume that no customers enter invalid food names. The Dictionary ‘price_list’ is set for you and use it in the code for your convenience. price_list={'Juice':30, 'Fried Rice':150, 'Burger':50, 'Pizza':110, 'Fried Chicken':90, 'Noodles':70} ====================================================== Function Call 01: take_order() Sample Input_01: Please enter the name of the items: Burger Juice Pizza X Sample Output_01: Total cost: 190 Explanation 1 : The customer ordered 3 things: Burger, Juice and a Pizza. So the cost of the three things are added, 50+30+110= 190 and is presented as the output. ================================================ Function Call 02: take_order() Sample Input_02: Please enter the name of the items: Burger Fried Rice Pizza X Sample Output_02: Total cost: 310 Explanation 2 : The customer ordered 3 things: Burger, Fried Rice and a Pizza. So the cost of the three things are added, 50+150+110= 310 and is presented as the output. ================================================ Function Call 03: take_order() Sample Input_03: Please enter the name of the items: Pizza Noodles X Sample Output_03: Total cost:180 Total income of the day: 680 Great Work Explanation 3 : Over here, the customer ordered 2 things: Pizza and Noodles. So the cost of the two things are added, 110+70= 180 and is presented as the output. The total income was 190 + 310 + 180 = 680. Since it crossed 500 tk, “Great work” is printed.
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Assume you work as a cashier in a restaurant. You must keep track of the
amount of money your restaurant earns each day and report it to your boss.
If a customer purchases something, that amount is added to the daily income
book.
Take a customer's order and if a customer enters an "X," the order is
complete, and print "Total cost of the items: ". In this way, 3 customers
can order at maximum as your restaurant only serves three customers per
day; after the service, print the day's total income; if the total money
exceeds 500tk, print "Great Work". Otherwise, print "Do Best Next Day."
Note: Write a function called “take_order()” that asks users to input food
names, calculate the amount and show it to the customer. When the last
customer buys, you need to also calculate the total income of the day and
show it at the end. Assume that no customers enter invalid food names.
The Dictionary ‘price_list’ is set for you and use it in the code for your
convenience.
price_list={'Juice':30, 'Fried Rice':150, 'Burger':50, 'Pizza':110, 'Fried
Chicken':90, 'Noodles':70}
======================================================
Function Call 01:
take_order()
Sample Input_01:
Please enter the name of the items:
Burger
Juice
Pizza
X
Sample Output_01:
Total cost: 190
Explanation 1 : The customer ordered 3 things: Burger, Juice and a Pizza.
So the cost of the three things are added, 50+30+110= 190 and is presented
as the output.
================================================
Function Call 02:
take_order()
Sample Input_02:
Please enter the name of the items:
Burger
Fried Rice
Pizza
X
Sample Output_02:
Total cost: 310
Explanation 2 : The customer ordered 3 things: Burger, Fried Rice and a
Pizza. So the cost of the three things are added, 50+150+110= 310 and is
presented as the output.
================================================
Function Call 03:
take_order()
Sample Input_03:
Please enter the name of the items:
Pizza
Noodles
X
Sample Output_03:
Total cost:180
Total income of the day: 680
Great Work
Explanation 3 : Over here, the customer ordered 2 things: Pizza and
Noodles. So the cost of the two things are added, 110+70= 180 and is
presented as the output.
The total income was 190 + 310 + 180 = 680. Since it crossed 500 tk, “Great
work” is printed.
Step by step
Solved in 2 steps