import java.util.Scanner; public class Payroll6 /** This class demonstrates * */ { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //int numEmployees=0; //use this as my counter int counter=0, idnum=0; String answer; System.out.println("Do you have data to enter? (Y/N) "); answer = scanner.next(); // this one is fine, but for the sake of the ex we did // it another way checking for n // while(answer.charAt(0)=='Y' || answer.charAt(0)=='y') { // the following stmt is an infinite loop since the condition // is always true // while (answer.charAt(0) !='N' || answer.charAt(0) !='n') { while (answer.charAt(0) !='N' && answer.charAt(0) !='n') { //counter++; System.out.print("Enter ID number of employee: "); idnum = scanner.nextInt(); System.out.printf("Enter hours and rate for employee #%d: ",idnum); int hoursWorked=scanner.nextInt(); double payPerHour=scanner.nextDouble(); // calculate pay double weeklySalary=0.0; if (hoursWorked > 40) { System.out.println("You worked overtime!"); // now let's calculate weekly salary with 1 1/2 pay for overtime weeklySalary = (hoursWorked-40)*1.5*payPerHour+40*payPerHour; } else { weeklySalary = hoursWorked * payPerHour; } System.out.printf("Weekly salary for employee #%d is: $%.2f. You worked %d " + "hours at %.2f rate.\n", idnum, weeklySalary,hoursWorked, payPerHour); System.out.print("Do you want to enter another employee? Y/N "); answer = scanner.next(); } } }