Google Search

Monday, March 2, 2015

write a Java program to print the greatest number


Step 1: Start

Step 2: Read a, b and c

Step 3: if a>b and a>c print “A is greatest”.

Step 4: else if b>c print “B is greatest”.

Step 5: else print “C is greatest”.

PROGRAM: import*; 
class gtn


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)&&(a>c)) {System.out.println("A is greatest");} else if (b>c)


System.out.println("B is greatest");




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


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

12 21 32

C is greatest D:\JAVA>


Post a Comment