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 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.
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
Related Questions
A cloth manufacturing company offers discounts to the dealers and retailers. The discount is computed using the length of the cloth as per the following table:
Length of cloth Dealer's Discount Retailer's Discount Up to 1000 meters 20% 15% Above 1000 meters but less than 2000 meters 25% 20% More than 2000 meters 35% 25% Write a program in Java to input the length of the cloth and the total amount of purchase. The program should display a menu to accept type of customer — Dealer (D) or Retailer (R) and print the amount to be paid. Display a suitable error message for a wrong choice.
Using switch case, write a program to convert temperature from Fahrenheit to Celsius and Celsius to Fahrenheit.
Fahrenheit to Celsius formula: (32°F - 32) x 5/9
Celsius to Fahrenheit formula: (0°C x 9/5) + 32Using switch case statement in Java, create a program to convert rupee into dollar and dollar into rupee according to the user's choice. Assume conversion price: 1 Dollar = Rs.77.
Star mall is offering discount on various types of products purchased by its customers. Following table shows different type of products and their respective code along with the discount offered. Based on the code entered, the mall is calculating the total amount after deducting the availed discount. Create a program to calculate total amount to be paid by the customer.
Item Item Code Discount Laptop L 5% LCD D 7% XBox X 10% Printer P 11%