Loop returns at second input rather than first.
Could someone provide some input on why my loop is returning back to the second portion of the program? I would actually prefer that the first loop keep looping until "stop" is issued but at this point I will take any advice to have it start at step 1.
import java.util.Scanner;
public class Payrollb
{
public static void main( String[] args )
{
Scanner input = new Scanner( System.in );
int dept1;
double salary1;
double sum;
boolean contRun = true;
while (contRun)
{
System.out.println( "Enter Name of The Department:" );
String deptName = input.nextLine();
if(deptName.equalsIgnoreCase("stop")){
}
do
{
System.out.println("Enter The Number of Employees In The Department:" );
dept1 = input.nextInt();
if(dept1 < 0)
System.out.println("Number Must Be A Positive");
}
while(dept1 < 0);
do
{
System.out.println("Enter The Average Salary Of Employees:" );
salary1 = input.nextDouble();
if(salary1 < 0)
System.out.println("Number Must Be A Positive");
}
while(salary1 < 0);
sum = dept1 * salary1;
System.out.println( "For Department: " + deptName);
System.out.println( "Average Salary Per Employee Is: $" + sum );
}
}
}