import java.util.Scanner; public class Payroll7 /** This class demonstrates counting and summing * */ { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int numEmployees=0; //use this as my counter int idnum=0; double totalWages=0.0; Scanner keyboard = new Scanner(System.in); System.out.print("Enter ID number of employee, -1 to exit: "); idnum = keyboard.nextInt(); // REPEAT the next block until user enters -1 as idnum while(idnum != -1) { numEmployees++; 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; } totalWages+=weeklySalary; 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("Enter ID number of employee, -1 to exit: "); idnum = keyboard.nextInt(); } // fell out of loop, numEmployees should contain number of employees // that were processed System.out.println("The number of employees processed is: " + numEmployees + " and the total wages to pay is: " + totalWages); } }