This is a Java Program to Find the Biggest of 3 Numbers.
Enter any three integer numbers as an input. Now we check the first number against the second and third number. If it false then we check for second number against third. If it is also false then accordingly third number will be declared the largest number of the given three numbers.
Here is the source code of the Java Program to Find the Biggest of 3 Numbers. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
import java.util.Scanner;
public class Biggest_Number
{
public static void main(String[] args)
{
int x, y, z;
Scanner s = new Scanner(System.in);
System.out.print("Enter the first number:");
x = s.nextInt();
System.out.print("Enter the second number:");
y = s.nextInt();
System.out.print("Enter the third number:");
z = s.nextInt();
if(x > y && x > z)
{
System.out.println("Largest number is:"+x);
}
else if(y > z)
{
System.out.println("Largest number is:"+y);
}
else
{
System.out.println("Largest number is:"+z);
}
}
}
Output:
$ javac Biggest_Number.java $ java Biggest_Number Enter the first number:10 Enter the second number:17 Enter the third number:15 Largest number is:17
Sanfoundry Global Education & Learning Series - 1000 Java Programs.
advertisement
advertisement
Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.
Related Posts:
- Check Programming Books
- Practice Programming MCQs
- Check Java Books
- Practice BCA MCQs
- Apply for Java Internship