-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample07.java
More file actions
51 lines (35 loc) · 1.04 KB
/
Example07.java
File metadata and controls
51 lines (35 loc) · 1.04 KB
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
package nelioJavaExamples;
import java.util.Locale;
import java.util.Scanner;
public class Example07 {
public static void main(String[] args) {
// Instanciando utilittários:
Locale.setDefault(Locale.US);
Scanner sc = new Scanner(System.in);
// Entradas
System.out.println("Enter three numbers: ");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int higher = max(a, b, c); // Definindo que higher recebe a função max + parâmetros
showResult(higher); // Exibindo resultados com a função showResult
sc.close(); // Scanner close
}
// Função de verificação de maior número
public static int max (int a, int b, int c) {
int aux; // Variável local que existe apenas nessa função
if (a > b && a > c) {
aux = a;
} else if (b > c) {
aux = b;
} else {
aux = c;
}
// Retornando variável auxiliar:
return aux;
}
// Função que exibe o resultado da verificação
public static void showResult(int aux) {
System.out.println("Higher: " + aux);
}
}