forked from pikachu-17/java-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmax_and_min_by_methods.java
More file actions
36 lines (30 loc) · 986 Bytes
/
max_and_min_by_methods.java
File metadata and controls
36 lines (30 loc) · 986 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
import java.util.Scanner;
public class max_and_min_by_methods {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("enter three numbers: ");
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
max(a,b,c);
min(a,b,c);
}
static void min(int a, int b, int c) {
if(a<b&&a<c){
System.out.println("minimum number is "+a);
} else if (b<a&&b<c) {
System.out.println("minimum number is "+b);
}else {
System.out.println("minimum number is "+c);
}
}
static void max(int a, int b, int c){
if(a>b&&a>c){
System.out.println("maximum number is "+a);
} else if (b>a&&b>c) {
System.out.println("maximum number is "+b);
}else {
System.out.println("maximum number is "+c);
}
}
}