ICSE Class 10 Computer Applications
Question 36 of 43
Conditional Constructs in Java — Question 36
Back to all questions 36
Question Question 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 the discount.
import java.util.Scanner;
public class KboatClothDiscount
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter total cost: ");
double cost = in.nextDouble();
double amt;
if (cost < 2000) {
amt = cost - (cost * 5 / 100.0);
}
else if (cost < 5000) {
amt = cost - (cost * 25 / 100.0);
}
else if (cost < 10000) {
amt = cost - (cost * 35 / 100.0);
}
else {
amt = cost - (cost * 50 / 100.0);
}
System.out.println("Amount to be paid: " + amt);
}
}Output
