a) A local shop sells festival cookies at RM28.50 per box. The shop offers special discount for order of 20 boxes or more as shown helowa: Number of boxes Discount on total price More than 100 25% 80-100 20% 50-79 15% 20-49 10% Write a fragment of C++ code to accept the order quantity in boxes, then calculates and displays the total discount (if applicable) and total cost of the order. Prompts error message if invalid quantity is entered (zero or below). Display the total cost in 2 decimal places. Sample program run 1: Enter number of boxes you wish to order : -10 Sorry. Invalid order quantity. Sample program run 2: Enter number of boxes you wish to order: 50 Total discount is RM213.75 Total cost is RM1211.25

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section: Chapter Questions
Problem 7PP
icon
Related questions
Question

C++ Programming

a) A local shop sells festival cookies at RM28.50 per box. The shop offers special discount for
order of 20 boxes or more as shown belows:
Number of boxes
Discount on total price
More than 100
25%
80-100
20%
50-79
15%
20-49
10%
Write a fragment of C++ code to accept the order quantity in boxes, then calculates and
displays the total discount (if applicable) and total cost of the order. Prompts error message if
invalid quantity is entered (zero or below). Display the total cost in 2 decimal places.
Sample program run 1:
Enter number of boxes you wish to order : -10
Sorry. Invalid order quantity.
Sample program run 2:
Enter number of boxes you wish to order: 50
Total discount is RM213.75
Total cost is
RM1211.25
Transcribed Image Text:a) A local shop sells festival cookies at RM28.50 per box. The shop offers special discount for order of 20 boxes or more as shown belows: Number of boxes Discount on total price More than 100 25% 80-100 20% 50-79 15% 20-49 10% Write a fragment of C++ code to accept the order quantity in boxes, then calculates and displays the total discount (if applicable) and total cost of the order. Prompts error message if invalid quantity is entered (zero or below). Display the total cost in 2 decimal places. Sample program run 1: Enter number of boxes you wish to order : -10 Sorry. Invalid order quantity. Sample program run 2: Enter number of boxes you wish to order: 50 Total discount is RM213.75 Total cost is RM1211.25
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr