import java.util.Scanner; /** The Employee class will read in info about any number of * employees and caculate * the weekly salary for each employee. * This version uses a Structured Read Loop. */ public class EmployeeV4 { public static void main(String[] args) { int numEmployees=0; // this will count the number of employees Scanner sc = new Scanner(System.in); // numEmployees = sc.nextInt(); String name; double hours, rate; // Structured Read Loop, read first data value OUTSIDE of while loop System.out.println("Enter id number of first employee, -1 to exit: "); int idnum=sc.nextInt(); while (idnum != -1) { // Step 1: Read in name, hours, rate for employee 1 sc.nextLine(); System.out.println("Enter employee name for employee: "); name = sc.nextLine(); System.out.println("Enter hours and rate: "); hours = sc.nextDouble(); rate = sc.nextDouble(); System.out.println("Name: " + name + " hours: " + hours + " rate: " + rate); // Step 2: Calculate gross pay double pay; if (hours <= 40) { pay = hours * rate; } else { pay = 40 * rate + (hours-40)*1.5*rate; } System.out.println("gross pay is: " + pay); // Step 3: Subtract taxes from pay if (pay >= 1000){ pay -= .15 * pay; } else { pay -= .10 * pay; } System.out.println("net pay is: " + pay); numEmployees++; System.out.println("Enter id number of next employee, -1 to exit: "); idnum=sc.nextInt(); }// end whle loop // after fall out of while loop, print the number of employees System.out.println("We processed " + numEmployees + " employees."); } }