Ayuda en código
Publicado por Sebastian (8 intervenciones) el 13/05/2020 05:36:00
Hola! Me pueden ayudar con algo porfa, es urgente.
Lo que pasa es que el codigo me tira un error en la linea 92 y no tengo idea de como solucionarlo, he gastado horas y no lo he podido decifrar, se los agradeceria mucho
Alum[i]=datos.Datos();
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at TALLERES.ClaseAlumnos.main(ClaseAlumnos.java:92)
Código:
Lo que pasa es que el codigo me tira un error en la linea 92 y no tengo idea de como solucionarlo, he gastado horas y no lo he podido decifrar, se los agradeceria mucho
Alum[i]=datos.Datos();
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at TALLERES.ClaseAlumnos.main(ClaseAlumnos.java:92)
Código:
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
108
109
110
111
112
113
114
115
116
117
package TALLERES;
import java.util.*;
public class ClaseAlumnos{
private static final ClaseAlumnos[][] ClaseAlumnos = null;
private int DocIndentidad;
private String NomAlumno;
private String Materia;
private double Notas;
private static int NumA;
public ClaseAlumnos(int Doc,String NomAlu,String Mate,double Nota,int Numa) {
this.DocIndentidad=Doc;
this.NomAlumno=NomAlu;
this.Materia=Mate;
this.Notas=Nota;
this.NumA=Numa;
}
public ClaseAlumnos() {
}
public ClaseAlumnos Datos() {
Scanner sc = new Scanner(System.in);
ClaseAlumnos A = new ClaseAlumnos();
System.out.print("Doc.Identidad Alumno: " );
A.DocIndentidad= sc.nextInt();
sc.nextLine();
System.out.print("Nombre: ");
A.NomAlumno=sc.nextLine();
System.out.print("Materia: ");
A.Materia=sc.nextLine();
System.out.print("Nota: ");
A.Notas=sc.nextDouble();
return A;
}
public void mostrar(int Doc,ClaseAlumnos Most[]) {
boolean exist=false;
for(int i=0;i<Most.length;i++) {
if(Most[i].DocIndentidad==Doc) {
System.out.println("Alumno Encontrado: ");
System.out.println("Documento: "+Most[i].DocIndentidad);
System.out.println("Nombre: "+Most[i].getNomAlumno());
System.out.println("Materia: "+Most[i].Materia+" Nota: "+Most[i].Notas);
exist=true;
}
}
if(exist==false) {
System.out.println("El Alumno NO Existe");
}
}
public int getNuma() {
return NumA;
}
public int getDoc() {
return DocIndentidad;
}
public void setDocInd(int docInd) {
DocIndentidad = docInd;
}
public String getNomAlumno() {
return NomAlumno;
}
public void setNomAlumno(String nomAlumno) {
NomAlumno = nomAlumno;
}
public String getMateria() {
return Materia;
}
public void setMateria(String materia) {
Materia = materia;
}
public double getNotas() {
return Notas;
}
public void setNotas(double notas) {
Notas = notas;
}
public static void main(String[] args) {
int pass = 1;
Scanner sc = new Scanner(System.in);
ClaseAlumnos datos = new ClaseAlumnos();
ClaseAlumnos Alum[] = new ClaseAlumnos[NumA];
while(true) {
System.out.print("Cuantos Alumnos Ingresará? ");
NumA=sc.nextInt();
for(int i=0;i<NumA;i++) {
Alum[i]=datos.Datos();
}
System.out.println("----MENÚ PRINCIPAL----");
System.out.println("1- Ingresar Datos");
System.out.println("2- Buscar Alumno Por Documento");
System.out.println("3- Promedio De Los Estudiantes");
pass=sc.nextInt();
System.out.println("------");
for (int k=0;k<NumA;k++) {
System.out.println("Documento: "+Alum[k].getDoc()+" Nombre: "+Alum[k].getNomAlumno());
System.out.println("Materia: "+Alum[k].getMateria()+" Nota: "+Alum[k].getNotas());
System.out.println("--------------");
}
if(pass==2) {
System.out.println("Ingresa El Documento Del Alumno Deseas Visualizar:");
int sol=sc.nextInt();
datos.mostrar(sol, Alum);
}
System.out.println("Presiona 1 Para Volver Al Menú ó Cualquier Otro Numero Para Salir");
int dec=sc.nextInt();
if(dec!=1) {
break;
}
}
}
}
Valora esta pregunta


0