Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | IT Developer <?php echo $page_title; ?>
IT Developer

Conditional Constructs in Java

Chapter 8

Conditional Constructs in Java

Class 10 - Logix Kips ICSE Computer Applications with BlueJ


Share with a Friend

Java Program: Cloth Showroom Festival Discount Calculator


36. A cloth showroom has announced the following festival discounts on the purchase of items based on the total cost of the items purchased:

Total Cost

Discount Rate

Less than Rs. 2000

5%

Rs. 2000 to less than Rs. 5000

25%

Rs. 5000 to less than Rs. 10,000

35%

Rs. 10,000 and above

50%

Write a program to input the total cost and to compute and display the amount to be paid by the customer availing the discount.

import java.util.Scanner;

 

public class ClothShowroomDiscount {

    public static void main(String[] args) {

 

        // Title

        System.out.println("CLOTH SHOWROOM FESTIVAL DISCOUNT CALCULATOR");

        System.out.println("------------------------------------------");

 

        Scanner sc = new Scanner(System.in);

 

        double totalCost, discount = 0, amountPayable;

 

        System.out.print("Enter total cost of purchase (Rs.): ");

        totalCost = sc.nextDouble();

 

        if (totalCost < 2000)

            discount = totalCost * 0.05;

        else if (totalCost < 5000)

            discount = totalCost * 0.25;

        else if (totalCost < 10000)

            discount = totalCost * 0.35;

        else

            discount = totalCost * 0.50;

 

        amountPayable = totalCost - discount;

 

        System.out.println("Discount Amount : Rs. " + discount);

        System.out.println("Amount to Pay   : Rs. " + amountPayable);

 

        sc.close();

    }

}

Output

Sample Output 

CLOTH SHOWROOM FESTIVAL DISCOUNT CALCULATOR
------------------------------------------
Enter total cost of purchase (Rs.): 7200
Discount Amount : Rs. 2520.0
Amount to Pay   : Rs. 4680.0

📝 Explanation

  • Total cost is taken as input using Scanner
  • Discount rate is selected using if–else ladder
  • Discount is calculated as:

                Discount = Total Cost × Discount Rate

  • Final amount payable:

               Amount to Pay = Total Cost − Discount