Show Room (Slab) Version 1

Write a program to accept name, mobile number and the cost of purchased item from the user and calculate the payable amount after applying discount based on the given tariff.

  • First ₹1 to ₹1000 discount will be 3%.
  • Next ₹1001 to ₹5000 discount will be 5%.
  • Next ₹5001 to ₹ 10000 discount will be 8%.
  • More than ₹10000 discount will be 10%.
Java
import java.util.*;
class ShowRoom
{
    public static void main(String args[])
    {
        String name="";
        long mobile=0;
        double cost,amount,d=0.0;
        Scanner sc=new Scanner(System.in);
        System.out.print("Consumer name: ");
        name=sc.nextLine();
        System.out.print("Consumer's mobile number: ");
        mobile=sc.nextLong();
        System.out.print("Cost of the item purchased: ");
        cost=sc.nextDouble();
        System.out.println();
        if(cost>0&&cost<=1000)
        {
            d=cost*0.03;
        }
        else if(cost>1000&&cost<=5000)
        {
            d=(1000*0.03)+((cost-1000)*0.05);
        }
        else if(cost>5000&&cost<=10000)
        {
            d=(1000*0.03)+((5000-1000)*0.05)+((cost-5000)*0.08);
        }
        else if(cost>10000)
        {
            d=(1000*0.03)+((5000-1000)*0.05)+((10000-5000)*0.08)+((cost-10000)*0.1);
        }
        else
        {
            System.out.println("Cost can not be zero or negative");
        }
        amount=cost-d;
        System.out.println("Customer's Name: "+name);
        System.out.println("Customer's Mobile Number: "+mobile);
        System.out.println("Cost of the product: "+cost);
        System.out.println("Amount to be paid after discount: "+amount);
    }
}
Java