Java Program to Find the Largest Among Three Numbers
In this example, we are giving a program to the find the largest number among three numbers.
To find the largest number among three numbers:
# To find the largest number among three numbers
public class Largest {
public static void main(String[] args) {
double n1 = 27.3, n2 = 15, n3 = -57.8;
if ( n1 >= n2 && n1 >= n3)
System.out.println(n1 + " is the largest number.");
else if (n2 >= n1 && n2 >= n3)
System.out.println(n2 + " is the largest number.");
else
System.out.println(n3 + " is the largest number.");
}
}
Output:
27.3 is the largest number.