No puedo introducir datos en buscar = entrada.nextLine();
Publicado por Eduardo (1 intervención) el 15/05/2017 21:04:50
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
import java.util.Scanner;
public class ProyectoFinal {
public static void main (String []args){
Scanner entrada = new Scanner (System.in);
int op, ap=-1;
int s=2;
String buscar;
String nombre [] = new String [s];
String matricula [] = new String [s];
String carrera [] = new String [s];
String semestre [] = new String [s];
String promedio [] = new String [s];
if (ap<s)
{ ap++;
for(ap=0; ap<s; ap++)
{
System.out.println("Insertar Nombre de Alumno " +(ap+1)+ ":");
nombre [ap] = entrada.nextLine();
System.out.println("Insertar Matricula:");
matricula [ap] = entrada.nextLine();
System.out.println("Insertar Carrera:");
carrera [ap] = entrada.nextLine();
System.out.println("Insertar Semestre:");
semestre [ap] = entrada.nextLine();
System.out.println("Insertar Promedio:");
promedio [ap] = entrada.nextLine();
}
if (ap!=-1)//cambiar
{
System.out.println("\nImpresión de datos:");
for(ap=0; ap<s; ap++)
{
System.out.println("\nNombre de Alumno " +(ap+1)+ ": " +nombre[ap]);
System.out.println("Matrícula: " +matricula[ap]);
System.out.println("Carrera: " +carrera[ap]);
System.out.println("Semestre: " +semestre[ap]);
System.out.println("Promedio: " +promedio[ap]);
}
System.out.println("\n¿Buscar matrícula?\n1.- Si\n2.- No");
op=entrada.nextInt();
switch(op)
{
case 1: System.out.println("Insertar Matrícula a buscar: ");
buscar = entrada.nextLine();
for(ap=0; ap<s; ap++)
{
if(matricula[ap]==buscar)
{
System.out.println("\nMatrícula: " +matricula[ap]);
System.out.println("Nombre de Alumno: " +nombre[ap]);
System.out.println("Carrera: " +carrera[ap]);
System.out.println("Semestre: " +semestre[ap]);
System.out.println("Promedio: " +promedio[ap]);
}
}
break;
case 2: System.out.println("Fin");
break;
}
}
else
{
System.out.println("No hay datos");
}
}
else
{
System.out.println("No hay espacio disponible");
}
}
}
Valora esta pregunta
0