JY CHEN - Ask Anything, Learn Everything. Logo

In Computers and Technology / High School | 2025-07-08

Write a pseudocode that accepts the beverage order code and quantity, calculates the total charges based on the given price list, and prints the order and charges using a control structure. CODE | BEVERAGE | PRICE 1. | COFFEE | RM2.00 2. | TEA | RM1.50 3. | MILO | RM4.00 Example Input: BEVERAGE CODE: 1 QUANTITY: 2 Example Output: YOUR ORDER: COFFEE CHARGES: RM4.00

Asked by Dashavu9156

Answer (1)

To solve this problem, we need to write pseudocode that processes a beverage order by accepting an order code and quantity, calculating the total charges, and then printing the order details. This involves basic input and output operations along with a control structure to decide the pricing based on the input.
Here is the pseudocode to accomplish this task:
START
// Define the beverage prices SET coffee_price = 2.00 SET tea_price = 1.50 SET milo_price = 4.00
// Prompt the user for input PRINT "BEVERAGE CODE: " INPUT beverage_code
PRINT "QUANTITY: " INPUT quantity
// Initialize variables for order details SET beverage_name = "" SET charges = 0.00
// Determine the beverage and charges based on the code IF beverage_code == 1 THEN SET beverage_name = "COFFEE" SET charges = coffee_price * quantity ELSE IF beverage_code == 2 THEN SET beverage_name = "TEA" SET charges = tea_price * quantity ELSE IF beverage_code == 3 THEN SET beverage_name = "MILO" SET charges = milo_price * quantity ELSE PRINT "Invalid beverage code" STOP END IF
// Print the order and charges PRINT "YOUR ORDER: " + beverage_name PRINT "CHARGES: RM" + charges
END ;

Answered by IsabellaRoseDavis | 2025-07-21