Ver Mensaje Individual
  #6 (permalink)  
Antiguo 18/05/2016, 08:32
madison_sg
 
Fecha de Ingreso: noviembre-2015
Mensajes: 77
Antigüedad: 8 años, 5 meses
Puntos: 2
Respuesta: Programa do-while-for en java

Mira, hice este código que al parecer todo iba bien porque ya toma los datos y los envía a 3 textarea, pero no logro hacer que por ejemplo:
si se inscribe 6 alumnos y de estos 6, 4 van a football y 2 a baseball, no logro hacer que el contador me marque 4 registros y 2, sino que hace un conteo consecutivo y me manda 4 en football y 6 en baseball.

private void btningresarActionPerformed(java.awt.event.ActionEv ent evt) {
// TODO add your handling code here:
byte alumno, edad;

String football;
String baseball;
String basketball;
//entrada de datos
alumno = Byte.parseByte(txtalumno.getText());
//proceso
for(int i=1;i<=alumno;i=i+1)
{
do
{
edad=Byte.parseByte(JOptionPane.showInputDialog(th is,
"Ingrese la edad del alumno"+ i,"Notas",1));
} while(edad<12 || edad>14);
football="Football";
if(edad==12){
tafootball.setText("Edad: " + edad + " \nRegistrado en: " + football
+ "\nTotal registrados en equipo: " + i);


}else{
baseball="Baseball";
if(edad==13){
tabaseball.setText("Edad: " + edad + " \nRegistrado en: " + baseball
+ "\nTotal registrados en equipo: " + i);

}else{
basketball="Basketball";
tabasketball.setText("Edad: " + edad + " \nRegistrado en: " + basketball
+ "\nTotal registrados en equipo: " + i);
}
}
}
__________________
paco alonso