-
Notifications
You must be signed in to change notification settings - Fork 1
/
SmallestAndLargestNumber.java
67 lines (37 loc) · 1.45 KB
/
SmallestAndLargestNumber.java
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package ChapterTwo;
import java.util.Scanner;
public class SmallestAndLargestNumber {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int smallest;
int largest;
System.out.println("Enter number one");
int numberOne = input.nextInt();
System.out.println("Enter number two");
int numberTwo = input.nextInt();
System.out.println("Enter number three");
int numberThree = input.nextInt();
System.out.println("Enter number four");
int numberFour = input.nextInt();
System.out.println("Enter number five");
int numberFive = input.nextInt();
smallest =numberOne;
largest= numberOne;
if(numberTwo<smallest)
smallest = numberTwo;
if (numberThree<smallest)
smallest = numberThree;
if(numberFour<smallest)
smallest=numberFour;
if (numberTwo>largest)
largest = numberTwo;
if(numberThree>largest)
largest=numberThree;
if(numberFour>largest)
largest =numberFour;
if (numberFive>largest)
largest =numberFive;
System.out.printf("Largest of five integers is %d%n " , largest);
System.out.printf("Smallest of five integers is %d%n " , smallest);
}
}