-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinOfThree.java
More file actions
35 lines (29 loc) · 757 Bytes
/
Copy pathMinOfThree.java
File metadata and controls
35 lines (29 loc) · 757 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
/**
* MinOfThree.java
* Demonstrates the use of nested if statements.
*/
import java.util.Scanner;
public class MinOfThree
{
// Reads three integers from the user and determines the smallest value.
public static void main (String[] args)
{
int num1, num2, num3, min = 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)
min = num1;
else
min = num3;
else
if (num2 < num3)
min = num2;
else
min = num3;
System.out.println ("Minimum value: " + min);
}
}