Write a java program to input the total cost and compute and display the amount to be paid by the customer after availing the discount

Programming Example

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 (in Percentage)
Less than ₹ 2000
5%
₹ 2001 to ₹ 5000
25%
₹ 5001 to ₹ 10000
35%
Above ₹ 10000
50%

Write a program to input the total cost and compute and display the amount to be paid by the customer after availing the discount.

Solution

import java.util.*;
class Discount
{
    public static void main(String arr[])
    {
        int tc;
        float dis,r,ap;
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the total cost:");
        tc=sc.nextInt();
        if (tc<=2000)
            r=5;
        else if (tc<=5000)
            r=25;
        else if (tc<=10000)
            r=35;
        else
            r=50;
        dis=r/100*tc;
        ap=tc-dis;
        System.out.println("Amount Payable="+ap);
    }
}
Output


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad