Page 166 - CA_Blue( J )_Class9
P. 166
Example:
int bill=35000;
double discount;
if (bill>20000)
discount=0.2 * bill;
else if (bill>10000)
discount=0.1 * bill;
else
discount=0;
System.out.println(" Discount will be :"+ discount);
Program 5 Input the marks and print the grade according to the following criteria:
Marks Grade
>=80 A
>=60 B
<60 C
1 import java.util.*;
2 class grades
3 {
4 public static void main()
5 {
6 Scanner sc= new Scanner(System.in);
7 int m;
8 System.out.print("Enter the marks : ");
9 m=sc.nextInt();
10 if(m>=80)
11 System.out.println("Grade A as marks is " + m);
12 else if(m>=60)
13 System.out.println("Grade B as marks is " + m);
14 else
15 System.out.println("Grade C as marks is " + m);
16 }
17 }
You will get the following output:
the
164 Touchpad Computer Applications-IX

