KnowledgeBoat Logo

Computer Applications

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

Total CostDiscount Rate
Less than Rs. 20005%
Rs. 2000 to less than Rs. 500025%
Rs. 5000 to less than Rs. 10,00035%
Rs. 10,000 and above50%

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.

Java

Java Conditional Stmts

174 Likes

Answer

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

BlueJ output of A cloth showroom has announced the following festival discounts on the purchase of items based on the total cost of the items purchased: 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.

Answered By

58 Likes


Related Questions