hi;
I am trying to create a program that will return information stored as long as the word stop is not entered for the employee name, I cant get the program to work can some one help me with this. this what I have so far.

// payroll program upgrade
import java.util.Scanner; // program uses scanner

public class payroll5
{
   public static void main( String args[] )

   {
      Scanner input = new Scanner(System.in );
      String nameOfEmployee;

      double rateOfPay;
      rateOfPay = 0;
      double hours;
      double sum;

      System.out.println( "Please enter name of employee or stop to quit: " );
      nameOfEmployee = input.nextLine();
      while (!nameOfEmployee.equalsIgnoreCase(stop))
      {
         System.out.println( " enter employee name " );
         nameOfEmployee = input.nextLine();

         System.out.println( " Enter rate of pay: $ " );
         rateOfPay = input.nextDouble();
         while ( rateOfPay <= 0 )
         {
            System.out.println( " must enter a positive number: $ "  );
            rateOfPay = input.nextDouble();
         }


         System.out.println( "Enter Hours: " );
         hours = input.nextDouble();
         while ( hours <= 0 )
         {
            System.out.println( " hours must be a positive number" );
            hours = input.nextDouble();
         }
         sum = rateOfPay * hours;

         System.out.print(nameOfEmployee);
         System.out.printf( " 's weekly pay is : $%f\n", sum );

         System.out.println( "Enter employee name or stop to quit: " );
         nameOfEmployee = "";
         while (!nameOfEmployee.equalsIgnoreCase())
         {                                                                 
         nameOfEmployee = input.nextLine();
         }
         System.out.println( "End Program" );

      }

   }

}
String nameOfEmployee = "";
        String strRateOfPay = "";
        double dblRateOfPay  = 0;

        System.out.println("Enter employee name (type 'stop' to exit): ");
        InputStreamReader kbInput = new InputStreamReader(System.in);
        BufferedReader brIn = new BufferedReader(kbInput);


            do {
                try {
                    nameOfEmployee = brIn.readLine();

                    if (nameOfEmployee.equalsIgnoreCase("stop"))
                    {
                        break;
                    }
                } catch (IOException ex) {
                    System.err.println(ex);
                }

                try {
                    System.out.println("Enter employee pay rate: ");
                    strRateOfPay = brIn.readLine();
                    if (strRateOfPay.isEmpty())
                    {
                        dblRateOfPay = 0;
                    }
                    else
                    {
                        dblRateOfPay = Double.parseDouble(strRateOfPay);
                    }

                } catch (IOException ex) {
                    System.err.println(ex);
                }

                if (!(nameOfEmployee.equals("stop"))){
                    System.out.println("Name: " + nameOfEmployee);
                    System.out.println(dblRateOfPay);

                    System.out.println("Enter employee name (type 'stop' to exit): ");
                }

          } while (!(nameOfEmployee.equalsIgnoreCase("stop")));

    }

ok I guess I should have said that I was new to java, I am in IT 215 and what you gave me is beyond my inderstanding up to this point. Thanks for the response but could some one explain what it means so novice could understand.

// payroll program upgrade
import java.util.Scanner; // program uses scanner

public class payroll5
{

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

        double rateOfPay;
        rateOfPay = 0;
        double hours;
        double sum;

        System.out.println("Please enter name of employee or stop to quit: ");
        nameOfEmployee = input.nextLine();
        while (!nameOfEmployee.equalsIgnoreCase(stop))
        {
            System.out.println(" enter employee name ");
            nameOfEmployee = input.nextLine();

            System.out.println(" Enter rate of pay: $ ");
            rateOfPay = input.nextDouble();
            while (rateOfPay <= 0)
            {
                System.out.println(" must enter a positive number: $ ");
                rateOfPay = input.nextDouble();
            }


            System.out.println("Enter Hours: ");
            hours = input.nextDouble();
            while (hours <= 0)
            {
                System.out.println(" hours must be a positive number");
                hours = input.nextDouble();
            }
            sum = rateOfPay * hours;

            System.out.print(nameOfEmployee);
            System.out.printf(" 's weekly pay is : $%f\n", sum);

            System.out.println("Enter employee name or stop to quit: ");
            nameOfEmployee = "";
            while (!nameOfEmployee.equalsIgnoreCase())
            {
                nameOfEmployee = input.nextLine();
            }
            System.out.println("End Program");

        }

    }
}

Line 20 - Strings have quotes around them. Change it to this:

while (!nameOfEmployee.equalsIgnoreCase("stop"))

Line 48 - I assume this is supposed to be the same as line 20? I don't see any reason to have this while loop. You already have it on line 20.

Line 52 - Are you sure you want this inside the loop?

thank you all, you have helped me to complete the application, it compiles and runs as it is supposed to. again thank you.

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.