It is necessary to develop a program that allows managing the information to organize the fifth edition of a marathon. It is known that:
The distances of the race are (in km):
The sizes of the shirts can be:
It will be offered:
You want:
Take the following data:
Calculate:
My code so far is this:
int participantes = 5;
int km = 0;
int km10 = 0;
int km5 = 0;
int km2 = 0;
String talles = " ";
int talleS = 0;
int talleM = 0;
int talleL = 0;
int botella = 0;
int edad;
int edadPromedio;
int sumatoriaEdad = 0;
Scanner teclado = new Scanner(System.in);
for (int i = 1; i < participantes; i++) {
System.out.println(i + ".Ingrese la edad : ");
edad = teclado.nextInt();
edad++;
System.out.println(i + ".Ingrese la distancia que recorre : ");
km = teclado.nextInt();
System.out.println(i + ".Ingrese talle : ");
talles = teclado.next();
switch (km) {
case 10:
if (km == 10) {
System.out.println("Se ofrece 1 botella de agua.");
km10++;
botella++;
}
break;
case 5:
if (km == 5) {
System.out.println("Se ofrece 0.5 botella de agua.");
km5++;
botella++;
}
break;
case 2:
if (km == 2) {
if ((i % 4) == 0) {
System.out.println("Se ofrece 1 botella de agua cada cautro corredores.");
botella++;
}
km2++;
}
break;
default:
System.out.println("Error! Distancia inexistente");
break;
}
switch (talles) {
case "S":
if (talles == "S") {
if (i == 1) {
talleS++;
}
}
break;
case "M":
if (talles == "M") {
if (i == 1) {
talleM++;
}
}
break;
case "L":
if (talles == "L") {
if (i == 1) {
talleL++;
}
}
break;
default:
System.out.println("Error! talle inesxistente.");
break;
}
sumatoriaEdad += edad;
}
edadPromedio = sumatoriaEdad / 5;
System.out.println("Edad promedio : " + edadPromedio);
System.out.println("Cantidad de corredores por distancia : ");
System.out.println("Corredores de km 10 : " + km10);
System.out.println("Corredores de km 5 : " + km5);
System.out.println("Corredores de km 2 : " + km2);
System.out.println("Cantidad de remeras por talle que se deben comprar : ");
System.out.println("Talle S : " + talleS);
System.out.println("Talle M : " + talleM);
System.out.println("Talle L : " + talleL);
System.out.println("Cantidad de botellas de agua que se deben comprar : " + botella);