Page 283 - CA_Blue( J )_Class9
P. 283
Enter a number: 9
9 is not an even number
VARIABLE DESCRIPTION
NAME DATATYPE DESCRIPTION
a int Accepts a Number
Write a program to input two numbers and print whether they are equal and if not, print the
Program 7
greater number.
1 class nestedifelse //class name
2 {
3 public static void main(int a, int b) //Parameterized Function
4 {
5 if(a==b) //Checking equal or not
6 {
7 System.out.println("The numbers are equal");
8 }
9 else
10 {
11 if(a>b) //Checking whether a is greater than b
12 {
13 System.out.println(a + " is greater than "+ b);
14 }
15 else
16 {
17 System.out.println(b + " is greater than "+ a);
18 }
19 }
20 } //Close of main()
21 } //Close of class
You will get the following output:
When both the numbers are 5
The numbers are equal
When a = 8 and b = 4
8 is greater than 4
Internal Assessment 281

