- 3

Write a Java program to find the largest of three numbers

program should be in Java

16th Aug 2017, 8:41 PM
Yussif Gafaru
Yussif Gafaru - avatar
3 Antworten
+ 25
import java.util.*; public class Program { public static void main(String[] args) { Scanner inp = new Scanner(System.in); int a = inp.nextInt(); int b = inp.nextInt(); int c = inp.nextInt(); System.out.println(a>b?(a>c?a:c):(b>c?b:c)); } }
16th Aug 2017, 8:48 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 2
There is many ways. int a = 5; int b = 8; int c = 2; System.out.println(Math.max(Math.max(a, b), c));
16th Aug 2017, 8:52 PM
Boris Batinkov
Boris Batinkov - avatar
17th Aug 2017, 1:03 AM
Carlos J Sousa
Carlos J Sousa - avatar