Revision Programs

Set 3

Discount Problems

1.1. Sequence Construct

  1. Input name of a customer and purchase amount. Find discount and net amount. Discount rate is 10% of the purchase amount. Print all details.

2. Conditional Construct: Selection Statement

2.1. if

  1. Input purchase amount. Find discount and net amount using simple if.
    If amount is 5000 or above then discount rate is 10% of the amount (otherwise no need to calculate discount). Print purchase amount, discount and net amount.

2.2. if else

  1. Input purchase amount. Find discount and net amount.
    If amount is 5000 or above then discount rate is 10% of the amount, otherwise 8%.
    Print purchase amount, discount and net amount.

2.3. if else if else

  1. Input purchase amount. Find discount and net amount. Discount rate is as follows:
    If amount is 5000 or above then 10% of the amount
    If it is above 3000 then 8%
    Otherwise 5%
    Print discount and net amount.

2.4. Nested if else if

  1. Input purchase amount and category. Find discount and net amount; print details. The rate is given below:
    Amount Gents Dress Ladies Dress
    5000 or above 10% 12%
    3001 to 4999 8% 10%
    3000 and below 5% 8%

2.5. switch case

  1. Write a menu-driven program:
    1) Calculate discount and net amount. Discount rate is 10% on the amount
    2) Calculate tax and total. Tax is 12% on the amount.

3. Iterative Construct (Loop):

3.1. for

  1. Input name and purchase amount of n customers.
    If amount is 5000 or above then discount rate is 10% of the amount, if it is above 3000 then 8% otherwise 5%.
    Print bill for each customer. Also find and print total net amount collected before closing the shop. Bill Format is given below:
    Sl.No.NameAmountDiscountNet Amount
    1xxxxxxxxxxxx
    Total net amount collected: xxx