-
Notifications
You must be signed in to change notification settings - Fork 0
/
P105.java
107 lines (63 loc) · 1.64 KB
/
P105.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package aceptaelreto;
import java.util.*;
public class P105 {
static Scanner s;
static String calcularmenor(float[] d, String[] menor){
String m = menor[0];
float min = d[0];
boolean empate = false;
for (int i = 1; i < 6; i++){
if (d[i] < min) {
min = d[i];
m = menor[i];
empate = false;
} else if (d[i] == min){
empate = true;
}
}
return (empate)? "EMPATE":m;
}
static String calcularmayor(float[] d, String[] mayor){
String m = mayor[0];
float max = d[0];
boolean empate = false;
for (int i = 1; i < 6; i++){
if (d[i] > max) {
max = d[i];
m = mayor[i];
empate = false;
} else if (d[i] == max){
empate = true;
}
}
return (empate)? "EMPATE":m;
}
static float calcularmitjana(float[] d) {
float total = 0;
for (int i = 0; i < 6; i++) {
total += d[i];
}
return total/6;
}
static boolean cas() {
String[] dia = {"MARTES","MIERCOLES","JUEVES","VIERNES","SABADO","DOMINGO"};
float[] d = new float[6];
String M,m,mitj;
float media;
d[0] = s.nextFloat();
if (d[0] == -1)return false;
for (int i = 1; i < 6;i++)
d[i] = s.nextFloat();
M = calcularmayor(d, dia);
m = calcularmenor(d, dia);
media = calcularmitjana(d);
mitj = (d[5] > media) ? "SI":"NO";
System.out.printf("%s %s %s\n",M,m,mitj);
return true;
}
public static void main(String[] args) {
s = new Scanner(System.in);
while(cas());
s.close();
}
}