Question 5 This program will calculate the total amount a customer has to pay based on their order of fruit juice. Create a text file as shown below. Name the file as menu.txt. The content of the file represents the juice code, juice name and juice price. menu - Notepad File Edit Format View Help Je01 Apple 2.30 J002 Pineapple 1.90 Je03 Orange 1.70 Je04 Carrot 2.50 Create a FILE pointer called fread. Use this pointer to open the file menu.txt for reading. • Ask the user to enter the juice code and number of glasses. • Identify the price of the juice the customer ordered. • Calculate the total payment and display the bill. • If the joice code entered is wrong, display "The Juice Code is INVALID. Order is cancelled!". • Display the output as shown below. SAMPLE OUTPUT: Enter Juice Code Enter number of glasses : 2 : JO03 Juice : Orange (RM 1.70) Glasses : 2 Payment : RM 3.40
This
∙ Create a text file as shown below. Name the file as menu.txt. The content of the file represents the juice code, juice name and juice price.
∙ Create a FILE pointer called fread. Use this pointer to open the file menu.txt for reading.
∙ Ask the user to enter the juice code and number of glasses.
∙ Identify the price of the juice the customer ordered.
∙ Calculate the total payment and display the bill.
∙ If the joice code entered is wrong, display “The Juice Code is INVALID. Order is cancelled!”.
∙ Display the output as shown below.
SAMPLE OUTPUT: |
Enter Juice Code : J003 Enter number of glasses : 2 Juice : Orange (RM 1.70) Glasses : 2 Payment : RM 3.40 |
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images