Hello I need help for a project I could not finish because I do not know how to do that.
Well the problem is that the project is Arraylist that arraylist full of information on "projects" for that I ask the user the number of proy, name, budget and percentage of progress of the proy, what happens is that if I ask but what happens if the user wants to put another project, it does the same but it would be a project with different data.
In a menu I have an option that says "Consult specific project" so I ask for the proy number and automatically the prog pulls me the info of said project depending on the number.
and when I try to do that I get all the info that I got, that is, if the number of the first project is 1 and the second is 13 and the user wants to print only the info of 1 project and type 1 but also the proy 13 info comes out because everything was printed.
Help please!
Here the code that I have written:
public static void main(String[] args) {
ArrayList P1 = new ArrayList();
Scanner sc = new Scanner(System.in);
int op = 0, num, sn, x = 01, i, n;
String nom;
double pt, pr = 0;
do {
op = Integer.parseInt(JOptionPane.showInputDialog(null, " REGISTRO DE PROYECTOS\n"
+ "\n 1 - Registrar datos de proyecto\n"
+ "2 - Actualizar porcentaje de avance de proyectos\n"
+ "3 - Consultar un proyecto en especifico\n"
+ "4 - Mostrar datos de todos los proyectos\n"
+ "5 - Eliminar un registro de preyecto en especifico\n"
+ "6 - Eliminar todos los registros de proyecto\n "));
switch (op) {
case 1:
System.out.println("*************DATOS DEL PROYECTO *************");
System.out.println("\n");
System.out.println("Numero del proyecto:");
num = sc.nextInt();
P1.add(num);
System.out.println("Nombre del proyecto:");
nom = sc.next();
P1.add(nom);
System.out.println("Presupuesto para el proyecto:");
pt = sc.nextDouble();
P1.add(pt);
System.out.println("Porcentaje de avance del proyecto:");
pr = sc.nextDouble();
P1.add(pr);
break;
case 2:
System.out.println("Nuevo porcentaje de proyecto:");
pr = sc.nextInt();
if (pr == 100) {
JOptionPane.showMessageDialog(null, "*****ACTUALIZACION*****\n" + "PROYECTO CONCLUIDO");
} else {
JOptionPane.showMessageDialog(null, "*****ACTUALIZACION*****\n" + "PROYECTO EN EJECUCION");
}
System.out.println("\n");
System.out.println("***************************************************************************");
System.out.println("***************************************************************************");
System.out.println("\n");
case 3:
System.out.println("*****CONSULTA DE PROYECTO*****");
for (i = 0; i <= P1.size() - 1; i++) {
System.out.println(P1.get(i));
}
}
System.out.println("Desea volver al menu (SI = 1 / NO = 2)");
sn = sc.nextInt();
} while (sn == 1);