// 10/23/2017

/** The Payroll class calculates the Net Pay for two
 *  employees. This is version 5 of the Payroll class.
 *  This version uses a while loop illustrating different kinds
 * of conditions for terminating the loop.
 * 
 * 1.  read in a value
 * 2.  ask the user if he/she wants to continue
 * 3.  use sentinel
 *     (read from file)
 */

import java.util.Scanner;

public class Payroll5 {
  /**
   * pay is calculated by multiplying hours times rate, and
   * then subtracting 11% for taxes.
   */
  public static void main(String[] args)   {
    
       final double TAXES = .11; // employees pay 11% income tax
       double taxes=0.0, rate=0.0, pay=0.0; 
       int hoursWorked=0;
       String name;  
       Scanner readObject = new Scanner(System.in);
       int numEmployees;
       System.out.print("Enter the number of employees: ");
       numEmployees = readObject.nextInt();
       readObject.nextLine(); // to skip newline in input buffer
      // while loop to process employees
       while (numEmployees>0) {
         // prompt the user to enter a name
         System.out.print("Enter a name of employee: ");
         name = readObject.nextLine();
         // prompt the user to enter data for hours and rate
         System.out.print("Enter number of hours worked and rate of pay: ");     
         hoursWorked = readObject.nextInt();
         rate = readObject.nextDouble();
         pay = rate * hoursWorked;
         taxes = TAXES*pay;
         pay-=taxes;
         System.out.println("Name   Hours   Rate     Pay");
         System.out.println("----------------------------");
         System.out.printf("%s  %4d $%4.2f $%,8.2f\n",name, hoursWorked, rate, pay);
         numEmployees--;
         readObject.nextLine(); // to skip newline in input buffer
       }
  }
}

/** Lab assignment:
  
  */







