Google Search

Monday, March 2, 2015

write a Java program to find the greatest among 3 no’s using nested if Statement


Step 1: Start

Step 2: Class gtnnestedif

Step 3: Use if and compare a,b and c

Step 4: Print the greatest no

Step 5: Stop

PROGRAM: import*; class gtnnestedif


public static void main(String args[])throws IOException

{BufferedReader br= new BufferedReader(new InputStreamReader(; int a,b,c;
System.out.println("Enter the values"); a=Integer.parseInt(br.readLine()); b=Integer.parseInt(br.readLine()); c=Integer.parseInt(br.readLine()); if(a>b)


{System.out.println("A is greatest");} else

System.out.println("C is greatest");}} else if (b>c)

System.out.println("B is greatest");} else
{System.out.println("C is greatest");}}}


D:\JAVA>javac D:\JAVA>java clsgtn Enter the values:

10 20 34

C is greatest


Post a Comment