Computer Applications
A cloth showroom has announced festival discounts and the gifts on the purchase of items, based on the total cost as given below:
Total Cost | Discount | Gift |
---|---|---|
Up to ₹ 2,000 | 5% | Calculator |
₹ 2,001 to ₹ 5,000 | 10% | School Bag |
₹ 5,001 to ₹ 10,000 | 15% | Wall Clock |
Above ₹ 10,000 | 20% | Wrist Watch |
Write a program to input the total cost. Compute and display the amount to be paid by the customer along with the gift.
Java
Java Conditional Stmts
205 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();
String gift;
double amt;
if (cost <= 2000.0) {
amt = cost - (cost * 5 / 100);
gift = "Calculator";
}
else if (cost <= 5000.0) {
amt = cost - (cost * 10 / 100);
gift = "School Bag";
}
else if (cost <= 10000.0) {
amt = cost - (cost * 15 / 100);
gift = "Wall Clock";
}
else {
amt = cost - (cost * 20 / 100);
gift = "Wrist Watch";
}
System.out.println("Amount to be paid: " + amt);
System.out.println("Gift: " + gift);
}
}
Variable Description Table
Program Explanation
Output
Answered By
85 Likes
Related Questions
Write a program to input three unequal numbers. Display the greatest and the smallest number.
Sample Input: 28, 98, 56
Sample Output: Greatest Number: 98
Smallest Number: 28Given below is a hypothetical table showing rate of income tax for an India citizen, who is below or up to 60 years.
Taxable income (TI) in ₹ Income Tax in ₹ Up to ₹ 2,50,000 Nil More than ₹ 2,50,000 and less than or equal to ₹ 5,00,000 (TI - 1,60,000) * 10% More than ₹ 5,00,000 and less than or equal to ₹ 10,00,000 (TI - 5,00,000) * 20% + 34,000 More than ₹ 10,00,000 (TI - 10,00,000) * 30% + 94,000 Write a program to input the name, age and taxable income of a person. If the age is more than 60 years then display the message "Wrong Category". If the age is less than or equal to 60 years then compute and display the income tax payable along with the name of tax payer, as per the table given above.
An employee wants to deposit certain sum of money under 'Term Deposit' scheme in Syndicate Bank. The bank has provided the tariff of the scheme, which is given below:
No. of Days Rate of Interest Up to 180 days 5.5% 181 to 364 days 7.5% Exact 365 days 9.0% More than 365 days 8.5% Write a program to calculate the maturity amount taking the sum and number of days as inputs.
A Pre-Paid taxi charges from the passenger as per the tariff given below:
Distance Rate Up to 5 km ₹ 100 For the next 10 km ₹ 10/km For the next 10 km ₹ 8/km More than 25 km ₹ 5/km Write a program to input the distance covered and calculate the amount paid by the passenger. The program displays the printed bill with the details given below:
Taxi No. :
Distance covered :
Amount :