Wednesday, 30 January 2013

Write a program to find largest of three numbers

This java program finds largest of three numbers. The program ask you to enter three numbers say x,y,z are three number where we find largest among these numbers. The conditions is given below.

 import java.util.Scanner;  
 class largestnumbers  
 {  
 public static void main(String args[])  
 {  
 int x, y, z;  
 System.out.println("Enter three integers ");  
 Scanner in = new Scanner(System.in);  
 x = in.nextInt();  
 y = in.nextInt();  
 z = in.nextInt();  
 if ( x > y && x > z )  
 System.out.println("First number is largest.");  
 else if ( y > x && y > z )  
 System.out.println("Second number is largest.");  
 else if ( z > x && z > y )  
 System.out.println("Third number is largest.");  
 else   
 System.out.println("Entered numbers are not distinct.");  
 }  
 }  

No comments:
Write comments

Featured post

List of Universities in Karnataka offering M.Sc Computer Science

The post-graduate programme in Computer Science (M.Sc Computer Science) contains two academic years duration and having a four semesters....

Popular Posts

Copyright @ 2011-2016