Enter the data of n students (cut with "end *"). The course can be A or B. Name, course, grade, sex, age. Calculate and print:
I DO NOT KNOW HOW TO PRINT THE RESULTS BY WINDOW (jOPTIONPANE) AND CREATE THE COURT "END" WITH A QUESTION.
package tp; import java.util.Scanner; public class data {public static void main (String [] args) {
int i, edadA=0, edadB=0, cantA=0,cantB=0,edadG=0,notVA=0,notVB=0,cantVA=0,cantVB=0;
double predadA, predadB,predadG,prnotVA,prnotVB;
int notA=0, notB=0, cantaprA=0, cantaprB=0,cantaplA=0,cantaplB=0,canteG=0;
int nota[];
nota = new int[8];
String nombre[];
nombre = new String[8];
String curso[];
curso = new String[8];
String sexo[];
sexo = new String[8];
int edad[];
edad = new int[8];
Scanner input = new Scanner(System.in);
for(i=0;i<8;i=i+1)
{
System.out.printf("Ingrese nombre alumno %d: ",i+1 );
nombre[i] = input.next();
System.out.printf("Ingrese curso alumno ( A/B) %d: ",i+1 );
curso[i] = input.next();
System.out.printf("Ingrese nota alumno %d: ",i+1 );
nota[i] = input.nextInt();
System.out.printf("Ingrese sexo alumno (F/M) %d: ",i+1 );
sexo[i] = input.next();
System.out.printf("Ingrese edad alumno %d: ",i+1 );
edad[i] = input.nextInt();
// EDAD PROMEDIO GENERAL
edadG=edadG+edad[i];
canteG=canteG+1;
// EDAD PROMEDIO POR CURSO
if (curso[i].equals("a")|| curso[i].equals("A") ){
edadA= edadA+edad[i];
cantA=cantA+1; }
else {
edadB=edadB+edad[i];
cantB=cantB+1; }
// APROBADOS POR CURSO
if (nota[i]>=6){
if ( curso[i].equals ("a")|| curso[i].equals ("A")){
notA=notA+nota[i];
cantaprA=cantaprA+1; }
else {
notB=notB+nota[i];
cantaprB=cantaprB+1; }
}
// APLAZADOS POR CURSO
if (nota[i]<6){
if ( curso[i].equals ("a")|| curso[i].equals ("A")){
notA=notA+nota[i];
cantaplA=cantaplA+1;
}
else {
notB=notB+nota[i];
cantaplB=cantaplB+1;
}
}
// NOTA PROMEDIO VARONES POR CURSO
if (sexo[i].equalsIgnoreCase("m")) {
if (curso[i].equalsIgnoreCase("a"))
{
notVA=notVA+nota[i];
cantVA=cantVA+1;
}else {
notVB=notVB+nota[i];
cantVB=cantVB+1;
}
}
} // aca termina el for
// imprimir calculos
predadG=edadG/canteG;
System.out.print( "El promedio general de edad es: " + predadG + "\n" );
predadA=edadA/cantA;
System.out.print( "El promedio de edad del curso A es: " + predadA + "\n" );
predadB=edadB/cantB;
System.out.print( "El promedio de edad del curso B es: " + predadB + "\n");
System.out.print( "La cantidad de alumnos aprobados en el curso A es de: " + cantaprA+ "\n");
System.out.print( "La cantidad de alumnos aprobados en el curso B es de: " + cantaprB+"\n");
System.out.print( "La cantidad de alumnos aplazados en el curso A es de: " + cantaplA+"\n");
System.out.print( "La cantidad de alumnos aplazados en el curso B es de: " + cantaplB+"\n");
prnotVA=notVA/cantVA;
System.out.print( "El promedio de alumnos varones en el curso A es de: " + prnotVA+"\n");
prnotVB=notVB/cantVB;
System.out.print( "El promedio de alumnos varones en el curso B es de: " + prnotVB+"\n");
} }