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

3.2. while

  1. Input name and purchase amount of some customers using while loop.
    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
    The program should continue as long as user wishes.

3.3. do while

  1. Input name and purchase amount of some customers using do while loop.
    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
    The program should continue as long as user wishes.

3.4. Nested for Loop

  1. Input n customers’ name and each customer's m purchase amounts. Print total, discount (5% on total) and net amount of each customer.

4.1. S D Array

  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 a list of purchase with seriel number. Also find total net amount collected in the shop.
    Format:
    List of Purchase
    Sl. No.NameAmountDiscountNet Amount
    1------------
    2------------
    Total net amount collected: ---

4.2. D D Array

  1. Input 50 customers’ 7 days’ purchase amounts. Find each customer’s total purchase amounts and each day's total amounts.

5. Methods

5.1. Overloaded Methods

  1. W a p using overloaded methods void amount() to find followings:
    1) Find discount and net amount. Discount rate is 10% of purchase amount
    2) Find tax and total amount. Tax rate is 15% of sales amount

5.2. Overloaded Methods with Menu-driven

  1. Write a menu-driven program using overloaded methods void amount() to find followings:
    1) Find discount and net amount. Discount rate is 10% of purchase amount
    2) Find tax and total amount. Tax rate is 15% of sales amount

6.1. Constructor

  1. Define a class Discount. Data members / Instance variables: name, amount, discount and net.
    Member methods: 1) input() - to input name and purchase amount.
    2) calculate() – to find discount and net amount:
    If amount is 5000 or above then discount rate is 10% of the amount, if it is above 3000 then 8% otherwise 5%.
    3) display() – to display values. Write main() also.