I have a menu with a switch with 3 options that does the following:
In option 1 the user is requested all the necessary data. In option 2 I want to show this data that was saved.
The question is, how can I do this? How can I show the data that was saved in the variables in option 1?.
Code:
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Menu_1 extends Variables {
public static void main(String[]args) {
int opcion;
do{
opcion=Integer.parseInt(JOptionPane.showInputDialog(null,
" ELIJA LA OPCION QUE NECESITA UTILIZAR \n"+
"1.- Captura de datos \n"+
"2.- Consulta de datos \n"+
"3.- Finalizar \n"+
"INGRESE UNA OPCION(1-3)","MENU PRINCUPAL",JOptionPane.QUESTION_MESSAGE));
switch(opcion){
case 1:
int identificacion;
short edad;
long telefono;
int sueldo;
String direccion;
float estatura;
double deuda;
boolean datos;
char genero;
String nombre;
String estudios;
Short familiares;
Scanner teclado= new Scanner (System.in);
System.out.print("Diguite la direccion: ");
direccion= teclado.nextLine();
System.out.print("Diguite la identificacion: ");
identificacion= teclado.nextInt();
System.out.print("Diguite el nombre: ");
teclado.nextLine();
nombre= teclado.nextLine();
System.out.print("Diguite la edad: ");
edad= teclado.nextShort();
System.out.print("Diguite el telefono: ");
telefono= teclado.nextLong();
System.out.print("Diguite el sueldo: ");
sueldo= teclado.nextInt();
System.out.print("Diguite la estatura: ");
estatura= teclado.nextFloat();
System.out.print("Diguite la deuda: ");
deuda= teclado.nextDouble();
System.out.print("Diguite los estudios: ");
teclado.nextLine();
estudios= teclado.nextLine();
System.out.print("Diguite la cantidad de familiares: ");
familiares= teclado.nextShort();
System.out.print("digite su genero (Masculino o femenino):");
genero= teclado.next().charAt(0);break;
case 2:
//aqui va la opcion 2 mostrar contenido que fue capturado en la opcion 1, aquí el problema o de que otra manera hacer el menu funcional//
case 3: JOptionPane.showMessageDialog(null,"QUE TENGA BUEN DIA");System.exit(0);break;
default:JOptionPane.showMessageDialog(null, "ELIJA UNA OPCION VALIDA \n", "ERROR DE OPCION",JOptionPane.WARNING_MESSAGE);
} }while(opcion !=3);
}
}