java program for to find largest among three numbers

import java.io.*;
import java.util.*;
class largest_number{
public static void main(String args[]){
int num1,num2,num3;
System.out.println(“Enter three numbers one by one”);
Scanner sc=new Scanner(System.in);
num1=sc.nextInt();
num2=sc.nextInt();
num3=sc.nextInt();
if(num1>num2 && num1>num3)
System.out.println(“The greater number isn”+num1);
if(num2>num1 && num2>num3)
System.out.println(“The greater number isn”+num2);
if(num3>num1 && num3>num2)
System.out.println(“The greater number isn”+num3);
}
}

OUTPUT-
Enter three numbers one by one
6
9
8
The greater number is
9

Leave a Comment

Your email address will not be published. Required fields are marked *

Open chat