Computer Science, asked by sinhaankitalko, 1 year ago

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
Less than Rs.2000 5%
Rs. 2001 to 5000 25%
Rs. 5001 to 10000 35%
above Rs. 10000 50%

Write a program to input the total cost . Compute and display the amount to be paid by the costumer after availing the discount. MAKE USE OF SUITABLE FUNCTION/METHOD with parameters.

Answers

Answered by pareekpaarth203
181
import java.io.*;
class Discount_Showroom

   public static void main(String args[])throws IOException   
 {   
    InputStreamReader in=new InputStreamReader(System.in);     
  BufferedReader br=new BufferedReader(in);     
   System.out.println("Please Enter the total cost");     
  int cost=Integer.parseInt(br.readLine());   
     if (cost<2000)   
    {            int a= cost*5/100;   
        int b=cost-a;         
  System.out.println("Please pay "+b);   
     }     
  else if (cost>2000&&cost<=5000)     
   {         
   int a=cost*25/100;   
        int b=cost-a;       
    System.out.println("Please pay "+b);     
  }   
    else if (cost>5000&&cost<=10000)     
   {         
  int a=cost*35/100;     
       int b=cost-a;         
  System.out.println("Please pay "+b); 
      }     
  else      
   {            int a=cost*50/100;   
        int b=cost-a;       
     System.out.println("Please pay "+b); 
      }     
   System.out.println("Thank You,Please Visit Again"); 
  }
}

sinhaankitalko: its written to be done with functions so we have to do it with functions??????
Answered by The1sanegirl
114

Answer:

import java.util.*;

public class p1

{

   public static void main(String q[])

   {

       double a=0, d=0, am=0;

       Scanner z=new Scanner(System.in);

       System.out.println("Enter the total amount:");

       a=z.nextDouble();

       if(a<2000 && a==2000){

       d=(a*0.05);

       am=a-d;

       System.out.println(am);}

       if(a==2001 && a<=5000){

       d=(a*0.1);

       am=a-d;

       System.out.println(am);}

       if(a==5001 && a<=10000)

       d=(a*0.15);{

       am=a-d;

       System.out.println(am);}

       if(a>10000){

       d=(a*0.20);

       am=a-d;

       System.out.println(am);}

   

          }

       }

Explanation:

the programm i have written here is applicable. it is a simple programm, hope it helps.

Similar questions