-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrincipal3.java
More file actions
101 lines (80 loc) · 2.98 KB
/
Principal3.java
File metadata and controls
101 lines (80 loc) · 2.98 KB
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
import java.util.Scanner;
class Alumno {
String nombre;
String matricula;
String correo;
String telefono;
String promedio;
public void setNombre(String nom) {
nombre = nom;
}
public String getNombre() {
return nombre;
}
public void setMatricula(String mat) {
matricula = mat;
}
public String getMatricula() {
return matricula;
}
public void setCorreo(String cor) {
correo = cor;
}
public String getCorreo() {
return correo;
}
public void setTelefono(String tel) {
telefono = tel;
}
public String getTelefono() {
return telefono;
}
public void setPromedio(String prom) {
promedio = prom;
}
public String getPromedio() {
return promedio;
}
}
public class Principal3 {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
System.out.println("Ingrese la cantidad de alumnos: ");
int cantidadAlumnos = Integer.parseInt(scan.nextLine());
if (cantidadAlumnos <= 1) {
System.out.println("El tamaño del arreglo debe ser mayor que uno.");
scan.close();
return;
}
Alumno[] alumnos = new Alumno[cantidadAlumnos];
for (int i = 0; i < cantidadAlumnos; i++) {
Alumno alumno = new Alumno();
System.out.println("\nIngrese los datos para el alumno " + (i + 1) + ":");
System.out.println("Nombre del alumno: ");
String nombre = scan.nextLine();
alumno.setNombre(nombre);
System.out.println("Matricula: ");
String matricula = scan.nextLine();
alumno.setMatricula(matricula);
System.out.println("Correo: ");
String correo = scan.nextLine();
alumno.setCorreo(correo);
System.out.println("Telefono: ");
String telefono = scan.nextLine();
alumno.setTelefono(telefono);
System.out.println("Promedio: ");
String promedio = scan.nextLine();
alumno.setPromedio(promedio);
alumnos[i] = alumno;
}
System.out.println("\nDatos de los alumnos:");
for (Alumno alumno : alumnos) {
System.out.println("\nNombre del alumno: " + alumno.getNombre());
System.out.println("Matricula: " + alumno.getMatricula());
System.out.println("Correo: " + alumno.getCorreo());
System.out.println("Telefono: " + alumno.getTelefono());
System.out.println("Promedio: " + alumno.getPromedio());
}
scan.close();
}
}