- Home
- Chapter 1 - Object Oriented Programming Concepts
- Object Oriented Programming Concepts
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 2 - Introduction to Java
- Introduction to Java
- Multiple Choice Questions
- Assignment Questions
- Chapter 3 - Values and Data Types
- Values and Data Types
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 4 - Operators in Java
- Operators in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 5 - User-Defined Methods
- User-Defined Methods
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 6 - Input in Java
- Input in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 7 - Mathematical Library Methods
- Mathematical Library Methods
- Multiple Choice Questions
- Assignment Questions
- Chapter 8 - Conditional Constructs in Java
- Conditional Constructs in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 9 - Iterative Constructs in Java
- Iterative Constructs in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions and Programs
- Chapter 10 - Nested for loops
- Nested for loops
- Assignment Questions and Programs
- Chapter 11 - Constructors
- Constructors
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 12 - Library Classes
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 13 - Encapsulation and Inheritance
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 14 - Arrays
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 15 - String Handling
- Library Classes
- Multiple Choice Questions
- Assignment Questions
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
