Page 284 - CA_Blue( J )_Class9
P. 284
VARIABLE DESCRIPTION
NAME DATATYPE DESCRIPTION
st
a int Accepts 1 Number
nd
b int Accepts 2 Number
Write a program to input the price of an item and print the discount and discounted price
Program 8
according to the following criteria.
Price of Item Discount%
<=2,000/- 5%
2,001/- to 5,000/- 7.5%
5,001/- to 10,000/- 10%
>10,000/- 15%
1 import java.util.*; //Importing “util” package
2 class pricediscount //Class name
3 {
4 public static void main()
5 {
6 Scanner sc= new Scanner(System.in);
7 double pr, dis, dispr=0.0; //Declaration of variable
8 System.out.print("Enter the price of an item : ");
9 pr=sc.nextDouble();
10 if(pr<=2000) //checking of condition
11 dis = pr * 0.05;
12 else
13 if(pr<=5000)
14 dis = pr * 0.075;
15 else
16 if(pr<=10000)
17 dis = pr * 0.1;
18 else
19 dis = pr * 0.15;
20 dispr = pr-dis; //Discounted price
21 System.out.println("Price of the item : "+pr);
//Displaying of price, discount and discounted price
22 System.out.println("Discount : "+dis);
23 System.out.println("Discounted Price : "+dispr);
24 }
25 }
282 Touchpad Computer Applications-IX

