import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class payrate 
{


    public static void main(String[] args)
    {   




            String str;
            String name;
            double horasT; // horas trabajadas
            double rate;  // rate por hora 
            double salarioB; //  el salario bruto



            name = JOptionPane.showInputDialog ("Entre le nombre del empleado: ");

            do
            {
                str = JOptionPane.showInputDialog("Entre las horas trabajadas: ");
                horasT = Double.parseDouble(str);


                if(horasT <=0)
                {
                    JOptionPane.showMessageDialog(null, "No entreo suficiente datos, porfavor trate denuevo.");
                }// if horasT <=0
            }while(horasT <= 0);// do

            do
            {
                str = JOptionPane.showInputDialog("Entre el rate por hora: ");
                rate = Double.parseDouble(str);

                if(rate<=0)
                {
                    JOptionPane.showMessageDialog(null, "No entreo suficiente datos, porfavor trate denuevo.");
                }// 
            }while(rate <=0);


                    salarioB =getSalarioB(horasT, rate);
            mostrarLosResultados(name,horasT, rate, salarioB);



    }
        //metodo main       



        /**
         * 
         * 
         * @param horasT
         * @param rate
         * @return
         */

        private static double getSalarioB(double horasT, double rate) 
        {

            double salarioBruto;

            salarioBruto = horasT*rate;
            return salarioBruto;

        }// metodo getSalarioB

        /**
         * 
         * 
         * @param name
         * @param horasT
         * @param rate
         * @param salarioB
         */
        private static void mostrarLosResultados(String name, double horasT, double rate, double salarioB) 
        {
            DecimalFormat formatter = new DecimalFormat("#0.00");
            JOptionPane.showMessageDialog(null, "Nombre del empleado: " + name + "\n Las horas trabajadas son: " + horasT + 
                    "\n Su pago por hora es: $" + rate + "\n" + "Su salario bruto es: $" + formatter.format(salarioB ));



            JOptionPane.showInputDialog(null, "Empezar de nuevo? " + "\nEntre [1] para volver a empezar o [0] para salir" );

        }// metodo mostrarLosResultados



    }//payrate

OH MY GOD!! Spanish!! I have no idea what this piece of code do. Can you explain what it is you want to do? And maybe translate it to english so I can understand your code?

I'm not really up on java as I program in C usually. If this was c, I would stick the program in a loop, at the end of the loop you ask the question to the user, if they say "no" you just break from the lo op. If they answer "yes" you do nothing and allow your code to begin again

Example pseudocode:

Int x = 0
While(x)
{
Your code goes here
Ask user question if the wants to continue
If "no" , x=0. 
}

This is very rough idea to get you started. Any java pros please feel free to convert this to java and tidy up.

@kwadders: he has 2 do while loop. And I have no idea what they do. I am not sure if he has already accomplish what he has done or he has other problems. We just have to wait for him to reply to clear the air.

@Wen cai...Thanks.

You use a loop just like in C, except that instead of just breaking out of the loop you use a tidy do/while loop, eg

do {
   // stuff
   // get answer for y or n to continue
}  while (answer.equals("y"));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.