Help with a Java program, NetBeans

0

I have a program that is an ATM.  It gives you the options to withdraw, pay, check balance and no procedure. Every time an operation ends, it returns to the Menu, of course I used an < >

I did that at the beginning it will ask the name of the user, but now I want that when the person finishes a procedure, he asks again the name. But it does not come out ....

Here's my code:

public static void main(String[] args) {
        Scanner caja = new Scanner(System.in);

        Cuenta lidy = new Cuenta(600.0);
        Cuenta emma = new Cuenta(390.0);
        Cuenta zared = new Cuenta(200.0);



        String i="lidice";
        String k="emmanuel";
        String y="zared";
        String h;





        h=JOptionPane.showInputDialog(null,"BIENVENIDO al banco <<GCC>> \n ¿Cuál es su nombre?");

       if(i.equals(h)){

      String z;
        double g=0;
        while (g!= 4) {




        z = JOptionPane.showInputDialog("BIENVENIDO LIDY \n Escoge una opción  : \n \n CONSULTAR SALDO-----1 \n ABONAR-----2 \n RETIRAR----3 \n NINGÚN TRAMITE----4");
        g = Double.parseDouble(z);



        if (g == 1) {

            JOptionPane.showMessageDialog(null, "Escogiste Consultar Saldo es correcto?");

            JOptionPane.showMessageDialog(null, "El saldo de lidy es  :" + lidy.getSaldo());
        }

        if (g == 2) {

            String x;

            JOptionPane.showMessageDialog(null, "Escogiste  ABONAR es correcto?");

            x = JOptionPane.showInputDialog("Cuánto deseas abonar?:   ");
            double c;
            c = Double.parseDouble(x);
            lidy.setAbonar(c);

            JOptionPane.showMessageDialog(null, "Su daldo es:" + lidy.getSaldo());

        }


        if (g == 3) {

                String s;
                 JOptionPane.showMessageDialog(null, "Escogiste  RETIRAR es correcto?");

                s = JOptionPane.showInputDialog("Cuánto deseas Retirar?");
                double w;
                w = Double.parseDouble(s);

                if(w>lidy.getSaldo()){
                    JOptionPane.showMessageDialog(null, "No saldo");
                }
                if(w<lidy.getSaldo()){

                     lidy.setretirar(w);

                    JOptionPane.showMessageDialog(null, "Su saldo es de:" + lidy.getSaldo());
                }
                }
                }

                  }




                 if(k.equals(h)){


      String t;
        double u=0;
        while (u!= 4) {


        t = JOptionPane.showInputDialog("BIENVENIDO Emmanuel \n Escoge una opción  : \n \n CONSULTAR SALDO-----1 \n ABONAR-----2 \n RETIRAR----3 \n NINGÚN TRAMITE----4");
        u = Double.parseDouble(t);



        if (u == 1) {

            JOptionPane.showMessageDialog(null, "Escogiste Consultar Saldo es correcto?");

            JOptionPane.showMessageDialog(null, "El saldo de Emmanuel es  :" + emma.getSaldo());
        }

        if (u == 2) {

            String x;

            JOptionPane.showMessageDialog(null, "Escogiste  ABONAR es correcto?");

            x = JOptionPane.showInputDialog("Cuánto deseas abonar?:   ");
            double c;
            c = Double.parseDouble(x);
            emma.setAbonar(c);

            JOptionPane.showMessageDialog(null, "Su daldo es:" + emma.getSaldo());

        }


        if (u == 3) {

                String s;
                 JOptionPane.showMessageDialog(null, "Escogiste  RETIRAR es correcto?");

                s = JOptionPane.showInputDialog("Cuánto deseas Retirar?");
                double w;
                w = Double.parseDouble(s);

                if(w>emma.getSaldo()){
                    JOptionPane.showMessageDialog(null, "No saldo");
                }
                if(w<emma.getSaldo()){

                     emma.setretirar(w);

                    JOptionPane.showMessageDialog(null, "Su saldo es de:" + emma.getSaldo());

                }

                }



            }
                 }

         if(y.equals(h)){


      String tt;
        double uu=0;
        while (uu!= 4) {


        tt = JOptionPane.showInputDialog("BIENVENIDO Zared \n Escoge una opción  : \n \n CONSULTAR SALDO-----1 \n ABONAR-----2 \n RETIRAR----3 \n NINGÚN TRAMITE----4");
        uu = Double.parseDouble(tt);



        if (uu == 1) {

            JOptionPane.showMessageDialog(null, "Escogiste Consultar Saldo es correcto?");

            JOptionPane.showMessageDialog(null, "El saldo de Zared es  :" + zared.getSaldo());
        }

        if (uu == 2) {

            String x;

            JOptionPane.showMessageDialog(null, "Escogiste  ABONAR es correcto?");

            x = JOptionPane.showInputDialog("Cuánto deseas abonar?:   ");
            double c;
            c = Double.parseDouble(x);
            zared.setAbonar(c);

            JOptionPane.showMessageDialog(null, "Su daldo es:" + zared.getSaldo());

        }


        if (uu == 3) {

                String s;
                 JOptionPane.showMessageDialog(null, "Escogiste  RETIRAR es correcto?");

                s = JOptionPane.showInputDialog("Cuánto deseas Retirar?");
                double w;
                w = Double.parseDouble(s);

                if(w>zared.getSaldo()){
                    JOptionPane.showMessageDialog(null, "No saldo");
                }
                if(w<zared.getSaldo()){

                     zared.setretirar(w);

                    JOptionPane.showMessageDialog(null, "Su saldo es de:" + zared.getSaldo());
                  }

                }

            }

        }

    }
}
    
asked by Alí 19.09.2018 в 00:33
source

1 answer

0

Well here is the solution that I raised, I put my own code so that the example is more summarized

public static void main(String[] args) {
   Boolean salir = false;
   while(!salir){
      String accion = JOptionPane.showInputDialog(null,"¿Desea salir?, ingrese SI");
          if(accion.equals("SI")){
              salir = true;
          }
   }
   System.out.println("Hello world!");
}

And inside the while, you should put your 'ATM' code, what my code would be doing, is to always repeat the same actions until the user wants to leave

I hope it serves you!

    
answered by 19.09.2018 / 01:14
source