-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaxOfThree.java
More file actions
35 lines (29 loc) · 764 Bytes
/
Copy pathMaxOfThree.java
File metadata and controls
35 lines (29 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* MaxOfThree.java
* Demonstrates the use of nested if statements.
*/
import java.util.Scanner;
public class MaxOfThree
{
// Reads three integers from the user and determines the smallest value.
public static void main (String[] args)
{
int num1, num2, num3, max = 0;
Scanner scan = new Scanner (System.in);
System.out.println ("Enter three integers: ");
num1 = scan.nextInt();
num2 = scan.nextInt();
num3 = scan.nextInt();
if (num1 > num2)
if (num1 > num3)
max = num1;
else
max = num3;
else
if (num2 > num3)
max = num2;
else
max = num3;
System.out.println ("The largest number is: " + max);
}
}