// 9/27/2017

/** The Payroll class calculates the Net Pay for two
 *  employees. This is version 3 of the Payroll class.
 *  This version formats the output so it prints nicely.
 * %f is for float and double
 * %d is for int
 * %s is for String
 */

import java.util.Scanner;

public class Payroll3 {
  /**
   * 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; 
       int hoursWorked=0;
       String name;
      
       Scanner readObject = new Scanner(System.in);
       // 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();
       double pay = rate * hoursWorked;
       taxes = TAXES*pay;
       pay-=taxes;
       //System.out.println("Employee " + name + " worked " + hoursWorked
         //                + " hours at rate " + rate +"\n"
           //              + " pay is: " + pay);
       System.out.println("Name       Hours         Pay");
       System.out.println("----------------------------");
       System.out.printf("%s  %8d $%,13.2f\n",name, hoursWorked, pay);
      
       // now process 2nd employee
       readObject.nextLine(); // this is to skip the newline in input buffer
       System.out.print("Enter a name of employee: ");
       name = readObject.nextLine();
       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.printf("%s  %8d $%10.2f\n",name, hoursWorked, pay);
          
       }
}
