Here you will get java program to find largest of three numbers using if else statements.
import java.util.Scanner; public class LargestNumber { public static void main(String...s){ int x, y, z, largest; Scanner sc = new Scanner(System.in); System.out.println("Enter three numbers:"); x = sc.nextInt(); y = sc.nextInt(); z = sc.nextInt(); largest = x; if(y > x && y > z){ largest = y; } else if(z > x && z > y){ largest = z; } System.out.println("Largest number is " + largest); } }
Output
Enter three numbers:
4
10
5
Largest number is 10