Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

/*Write a program to find a greater number among given three numbers using

a) ternary operator
b) nested if.*/

/*import java.util.*;
class largernum
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int max;
max = (a > b) ? (a > c ? a : c) : (b > c ? b : c);
System.out.println("Maximum number "+ max);
}
}*/

import java.util.*;
class largernum
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
if( a>=b && a >= c)
System.out.println(a + " is the largest number.");

else if (b >= a && b >= c)


System.out.println(b + " is the largest number.");

else
System.out.println(c + " is the largest number.");
}
}

You might also like