write a Java program to print the greatest number - Computer Programming


C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

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 java.io.*; 
class gtn


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


BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); 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 clsgtn.java D:\JAVA>java clsgtn Enter the values:

12 21 32

C is greatest D:\JAVA>

No comments:

Post a Comment