Scanner super importante
Publicado por Un simple alumno (2 intervenciones) el 15/11/2020 03:20:29
Mi problema es que mi programa es muy largo. Luego de una introducción de mi equipo, este programa va a pedir que ingreses la cantidad de alumnos a registrar (este programa pide que ingreses una cantidad de alumnos a registrar, y luego, en base a la cantidad que elegiste, va a pedirte cierta cantidad de nombres y notas (es para profesores principalmente)), pero, una vez que ingresas el número, te imprime null tantas veces hallas puesto el número.
Ejemplo: Ingreso 20, imprime 20 null en distintas líneas.
El programa es este:
Si, es bastante largo.
Postdata: lo estoy haciendo en eclipse, y es muy básico ya que recién estoy aprendiendo a programar.
Ejemplo: Ingreso 20, imprime 20 null en distintas líneas.
El programa es este:
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
import java.util.Scanner;
public class proyecto{
static void Inicio(){
EsperarL();
System.out.print("De los creadores de:");
EsperarL();
System.out.print(" Profe,se puede trabajar solo?\n");
EsperarML();
System.out.println("Llegaron...");
EsperarSusp();
System.out.println("");
System.out.println("| ----- ----- ----- ---- | | ----- ----- --------- ----- ---- ");
System.out.println("| | | | | | | | | | | | | | | ");
System.out.println("| | | | | | | | | | | | | | | ");
System.out.println("| | | ----- | |---| | | | |----- | |-----| ---- ");
System.out.println("| | | | | | | | | | | | | | | ");
System.out.println("| | | | | | | | | | | | | | | ");
System.out.println(" ------ ----- ----- ----- | | |______| ----- ----- | | | ---- ");
EsperarML();
for(int e=0;e<=30;e++){System.out.println(" \n ");}}
static void EsperarSusp(){try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}}
static void Esperar(){try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}}
static void EsperarML(){try {
Thread.sleep(3500);
} catch (InterruptedException e) {
e.printStackTrace();
}}
static void EsperarL(){try {
Thread.sleep(2500);
} catch (InterruptedException e) {
e.printStackTrace();
}}
public static void main(String[]args){
Inicio();
Scanner leer=new Scanner(System.in);
int na;
System.out.println("Ingrese la cantidad de alumnos a registrar");
na=leer.nextInt();
leer.nextLine();
int i;
int[] notal=new int[na];
String noalumno[]=new String[na];
for(i=0;i==na;i++){
do{
System.out.println("Ingrese el nombre del alumno");
noalumno[i]=leer.nextLine();
System.out.println("Ahora ingrese su nota");
notal[i]=leer.nextInt();
leer.nextLine();
}while((notal[i]>1) & (notal[i]<12));
}
for(i=0;i<na;i++) {System.out.println(noalumno[i]);
switch(notal[i]) {
case 1: System.out.println("#\n#\n#\n");
Esperar();
break;
case 2: System.out.println("# #\n# #\n# #\n");
Esperar();
break;
case 3: System.out.println("# # #\n# # #\n# # #\n");
Esperar();
break;
case 4: System.out.println("# # # #\n# # # #\n# # # #\n");
Esperar();
break;
case 5: System.out.println("# # # # #\n# # # # #\n# # # # #\n");
Esperar();
break;
case 6: System.out.println("# # # # # #\n# # # # # #\n# # # # # #\n");
Esperar();
break;
case 7: System.out.println("# # # # # # #\n# # # # # # #\n# # # # # # #\n");
Esperar();
break;
case 8: System.out.println("# # # # # # # #\n# # # # # # # #\n# # # # # # # #\n");
Esperar();
break;
case 9: System.out.println("# # # # # # # # #\n# # # # # # # # #\n# # # # # # # # #\n");
Esperar();
break;
case 10: System.out.println("# # # # # # # # # #\n# # # # # # # # # #\n# # # # # # # # # #\n");
Esperar();
break;
case 11: System.out.println("# # # # # # # # # # #\n# # # # # # # # # # #\n# # # # # # # # # # #\n");
Esperar();
break;
case 12: System.out.println("# # # # # # # # # # # #\n# # # # # # # # # # # #\n# # # # # # # # # # # #\n");
Esperar();
break;}
}
}
}
Postdata: lo estoy haciendo en eclipse, y es muy básico ya que recién estoy aprendiendo a programar.
Valora esta pregunta


0