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 reads until the end of the input by calling
  * hasNext() 
  * (still using the keyboard).
  * ALSO:  we added summing all pay values.
  */
public class EmployeeV5 {
  
 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;
   int idnum;
   double sum=0.0;
   System.out.println("Enter id number of next employee ^D to exit: ");
   // while there is data to be read
   while (sc.hasNext()) {
     
      // Step 1: Read in idnum, name, hours, rate for employee 1
      idnum=sc.nextInt();
      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);
      sum+=pay;
      numEmployees++;
      System.out.println("Enter id number of next employee: ");
      //idnum=sc.nextInt(); removed this since it not necessary
   }// end while loop
   // after fall out of while loop, print the number of employees and total pay
   System.out.println("We processed " + numEmployees + " employees."
                     + " Total pay is: " + sum);
 }
}