how to I keep recalling the program?

If the user wants to enter in another employee, they should be able to. Problem is, I can't seem to make it start over. The 'stop' ends the program, but I need the program to start over without the user initiating it.

Help!!!!

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

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

{

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

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

}

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

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

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

{

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

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

}

product = number1 * number2; // multiply numbers

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

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

}//end main method

}//end class PayrollProgram

[2074 byte] By [4zlimita] at [2007-11-27 6:17:30]
# 1

1. Don't put all your code in the main method. Break it up into smaller sections, each in their own method.

2. Use a loop.

public void run() {

while user hasnt chosen stop {

// method calls

ask user to stop or not

}

}

floundera at 2007-7-12 17:30:26 > top of Java-index,Java Essentials,New To Java...