A bookshop gives discount to customers as follows:
• Students get 10% discount,
• Book dealers get 12% discount and
• Pensioners get 15% discount.
• All other customers get 10% discount only if their total purchases are more than R200.
You are requested to write two versions of a program that calculates and displays the final amount that is
due, after discount.
(i) The first version of the program uses a switch statement to implement the above program.
(ii) The second version of the program uses nested-if statements.
Hint:
Use the following variables:
float amount; // the amount due before discount
char customerType; // the type of customer: 'S' (student) or
// 'D' (dealer) or 'P' (pensioner) or
COS1511/103/0/2022
5
// 'O'(other) float discount,
Comments
Leave a comment