-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaxAndMin.java
More file actions
44 lines (27 loc) · 817 Bytes
/
Copy pathMaxAndMin.java
File metadata and controls
44 lines (27 loc) · 817 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
36
37
38
39
40
41
42
43
44
import java.util.Scanner;
public class MaxAndMin {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n1 = in.nextInt();
int n2 = in.nextInt();
int n3 = in.nextInt();
int n4 = in.nextInt();
int n5 = in.nextInt();
int max = maxOf3(n1,n2,n3);
max = maxOf3(max,n4,n5 );
System.out.println("Maximum: " + max);
System.out.println("Minimum: " + minOf3( minOf3(n1,n2,n3),n4,n5));
}
public static int maxOf3(int r, int s, int t) {
int maxi ;
maxi = Math.max(r, s);
maxi = Math.max(maxi, t);
return maxi ;
}
public static int minOf3(int r, int s, int t) {
int mini ;
mini = Math.min(r, s);
mini = Math.min(mini, t);
return mini ;
}
}