top of page

This Java program will find the largest number among the three inputed numbers

  • Writer: Nelson John
    Nelson John
  • Nov 22, 2017
  • 1 min read

import java.util.Scanner;

public class Largest_Ternary

{

public static void main(String[] args)

{

int a, b, c, d;

Scanner s = new Scanner(System.in);

System.out.println("Enter all three numbers:");

a = s.nextInt();

b = s.nextInt();

c = s.nextInt();

d = c > (a > b ? a : b) ? c : ((a > b) ? a : b);

System.out.println("Largest Number:"+d);

}

}

This is what the output should look like

Enter all three numbers:

5

6

7

Largest Number:7

Facebook: ayamnelrodinho1@gmail.com

Yahoo: talk2nelsonjohn2dat@yahoo.com

Whatsapp: +2349034595610

PLEASE KINDLY SHARE WITH FELLOW PROGRAMMERS AND ALSO SUBSCRIBE TO MY BLOG

FOR MORE FEEDS.


 
 
 

Comments


bottom of page