Can't make if..else work for me!

I am trying to have the program check for positive numbers and I can't get it to check it for me. Here is the coding:

import java.util.Scanner; // program uses class Scanner

public class PayrollProgram {

/** Creates a new instance of PayrollProgram */

public PayrollProgram() {

}

//main method begins execution of Payroll Program java application

public static void main(String[]args)

{

// create Scanner to obtain input from command window

Scanner input = new Scanner( System.in );

int number1; // hourly rate

int number2; // hours

int product; // product of number1 and number2

System.out.println("Please enter your name or stop to quit the program:");//prompt

String nameOfEmployee=input.nextLine();

if(nameOfEmployee.equals("stop"))//Check whether user has entered stop

{

System.out.println("Ending program");

}

else

System.out.println("Enter hourly rate:$");//prompt

number1 = input.nextInt(); // read first number

if (number1 <=0)//prompt until user enters positive value

{

System.out.print ("Hourly rate must be positive. Please enter hourly rate again");//prompt user to enter in hourly rate again

}

else

System.out.println( "Enter hours: " ); // prompt

number2 = input.nextInt();//read second number

if (number2 <=0)//prompt until user enters positive value

{

System.out.print ("Hours must be positive. Please enter hours worked again");//prompt user to enter in hours worked again

}

product = number1 * number2; // multiply numbers

System.out.print( nameOfEmployee ); // display employee name

System.out.printf("'s weekly pay is $%d\n",product);

} //end method main

} //end class PayrollProgram

Here is the outcome:

Please enter your name or stop to quit the program:

af

Enter hourly rate:$

-5

-5

Hourly rate must be positive. Please enter hourly rate againHours must be positive. Please enter hours worked againaf's weekly pay is $25

BUILD SUCCESSFUL (total time: 7 seconds)

I have to hit enter twice to get the last message. How do I get it to work at the end?

Thank the stars for you all!

[2316 byte] By [4zlimita] at [2007-11-27 5:36:21]
# 1
I figured it out.Thanks anyway!
4zlimita at 2007-7-12 15:06:53 > top of Java-index,Java Essentials,New To Java...
# 2
study the while loop, it will lead you to success.
petes1234a at 2007-7-12 15:06:53 > top of Java-index,Java Essentials,New To Java...
# 3

Other recommendations (for free!)

Try to make your variable names more meaningful (and consider using double for some of the variables rather than int):

double hourlyRate; // hourly rate

double hoursWorked; // hours

double totalPay; // product of number1 and number2

is easier to read than number1, number2, and product.

Last but not least, use code tags when posting code here.

this is easier to read

hourlyRate = -1;

while (hourlyRate < 0)

{

System.out.print("Enter hourly rate: ");

hourlyRate = input.nextDouble();

if (hourlyRate < 0)

{

System.out.print("Hourly rate must be positive. Please enter hourly rate again: ");

}

}

than this:

hourlyRate = -1;

while (hourlyRate < 0)

{

System.out.print("Enter hourly rate: ");

hourlyRate = input.nextDouble();

if (hourlyRate < 0)

{

System.out.print("Hourly rate must be positive. Please enter hourly rate again: ");

}

}

petes1234a at 2007-7-12 15:06:53 > top of Java-index,Java Essentials,New To Java...