Wednesday, 11 March 2015

[JAVA] [ICSE 2006 Answer 5] Calculating Bill Amount

Question:
ICSE 2006 Question 5
A cloth showroom has announced the following festival discounts on the purchase of items, based on the total cose of the items puchased:
TOTAL COST                   DISCOUNT
Less than Rs.2,000                 5%
Rs.2,001 to Rs.5,000              25%
Rs.5,001 to Rs.10,000             35%
Above Rs.10,000                   50%
Write a program to input the total cost and to compute and display the amount to be paid by the customer after availing the discount.

Source Code:
public class ICSE2006_5
{
    public static void main(double cost)throws Exception
    {
        int discount=0;
        if(cost<=2000)
            discount=5;
        else if(cost<=5000)
            discount=25;
        else if(cost<=10000)
            discount=35;
        else
            discount=50;
        System.out.println("The cost to be paid by the customer after availing the discount of "+discount+"% is Rs. "+(cost*(100-discount)/100)+".");
    }
}


Result:
INPUT:
5901.45
OUTPUT:
The cost to be paid by the customer after availing the discount of 35% is Rs. 3835.9425.

No comments:

Post a Comment