Friday, October 21, 2011

Cloth Showroom

// A cloth showroom has announced the following discounts on the purchase of items, based on the total cost of the items purchased:
// Total cost           Discount (in Percentage)
// Less than Rs. 2000       5%
// Rs. 2001 to Rs. 5000     25%
// Rs. 5001 to Rs. 10000    35%
// Above Rs. 10000          50%
// Write a program to input the total cost and to compute and display the amount to be paid by the customer after availing the discount.

// VARIABLE DESCRIPTION
//DISCOUNT=DISCOUNT OFFERED
//TOTALCOST=THE COST AFTER AVAILING DISCOUNT
//COST=COST BEFORE AVAILING DISCOUNT
//SAVE= TOTAL MONEY SAVED
//


import java.io.*;
import java.util.*;
class CLOTH_SHOWROOM_BILLING
{
    private static double totalcost,cost,save;
    private static double discount;
    private static int num;
    public static void main(String args[])throws IOException
    {
        System.out.println("...............................................................................................................................................");
        System.out.println("");
        System.out.println("                                       .........................................................");
        System.out.println("                                       .          ENTER THE NUMBER OF THE PRODUCTS WHERE :     .");
        System.out.println("                                       .          LESS THAN Rs.2000      5% DISCOUNT           .");                      
        System.out.println("                                       .          Rs. 2001 to Rs. 5000   25% DISCOUNT          .");                        
        System.out.println("                                       .          Rs. 5001 to Rs. 10000  35% DISCOUNT          .");                           
        System.out.println("                                       .          Above Rs. 10000       50% DISCOUNT           .");
        System.out.println("                                       .........................................................");
        System.out.println("");
        System.out.println("...............................................................................................................................................");
        System.out.println("");
        InputStreamReader reader=new InputStreamReader(System.in);
        BufferedReader input=new BufferedReader(reader);
        System.out.println("ENTER THE COST OF THE PRODUCT TO BE BOUGHT");
        System.out.print("USER INPUT :");
        try
        {
            cost=Double.parseDouble(input.readLine());
        }
        catch(Exception b)
        {
            System.out.println("");
            System.out.println("\t\tERROR FOUND : YOU HAVE TO ENTER ONLY INTEGERS PLEASE RERUN THE PROGRAM");
            System.exit(0);
        }
        choice();
        if(num==0||num<0)
        {
            System.out.println("THANKYOU FOR YOUR COOPERATION THE PROGRAM WILL NOW EXIT");
            System.exit(0);
       }
    }
  
    private static void choice()
    {
        if(cost<=2000)
        {
            System.out.println("");
            discount=5/100.0*cost;
            System.out.println("THE DISCOUNT AVAILABLE FOR THIS PRODUCT IS 5%");
            System.out.println("");
            totalcost=cost-discount;
            save=discount;
            System.out.println("");
            bill();
        }
        else if (cost>=2001&&cost<=5000)
        {
            System.out.println("");
           discount=25/100.0*cost;
            System.out.println("THE DISCOUNT AVAILABLE FOR THIS PRODUCT IS 25%");
            System.out.println("");
            totalcost=cost-discount;
            save=discount;
            System.out.println("");
            bill();
        }
        else if (cost>=5001&&cost<=10000)
        {
            System.out.println("");
            discount=35/100.0*cost;
            System.out.println("THE DISCOUNT AVAILABLE FOR THIS PRODUCT IS 35%");
            System.out.println("");
             totalcost=cost-discount;
            save=discount;
            System.out.println("");
            bill();
        }
        else if (cost>10001)
        {
            System.out.println("");
           discount=50/100.0*cost;
            System.out.println("THE DISCOUNT AVAILABLE FOR THIS PRODUCT IS 50%");
            System.out.println("");
             totalcost=cost-discount;
            save=discount;
            System.out.println("");
            bill();
        }
    }
    private static void bill()
    {
        Date date=new Date();
        System.out.println("...............................................................................................................................................");
        System.out.println("");
        System.out.println("                                       .........................................................");
        System.out.println("                                       .                          "+date+".");
        System.out.println("                                       .      THE ACTUAL COST OF THE PRODUCT IS "+cost+"        ");
        System.out.println("                                       .      TOTAL COST TO BE PAID IS "+totalcost+"            ");                        
        System.out.println("                                       .      TOTAL MONET SAVED IS "+save+"                     ");                           
       
        System.out.println("                                       .........................................................");
        System.out.println("");
        System.out.println("...............................................................................................................................................");
        System.out.println("");
       
    }
}

No comments:

Post a Comment