/** * File CISC370HOME/exercise-solns/grossPay/Payroll.java * A main program that prompts for employee data and computes the * gross pay for the pay period. * * The classes Name and Employee have been put into the package * grossPay. This file imports that package. It will not compile * in the directory $CISC370HOME/example-progs/grossPay/. * Move it to another directory before compiling it. Alternatively, * remove the package statements from the files Name.java and * Employee.java in this directory. */ import corejava.Console; import java.text.NumberFormat; import grossPay.*; class Payroll { /** * Class methods (i.e., static methods) */ public static void main( String args[] ){ double hoursWorked; String fName; System.out.println( "Enter employee's first name, last name, hourly pay rate"); System.out.println( "and hours worked with the numbers on separate lines. "); Console.printPrompt( "Or type quit to terminate:"); fName = Console.readWord(); // Get local currency format to format weekly pay amount NumberFormat cf = NumberFormat.getCurrencyInstance(); while ( !fName.equals("quit") ) { Employee e = new Employee(fName,Console.readWord(), Console.readDouble("")); hoursWorked = Console.readDouble(""); System.out.println("The gross weekly pay for " + e.getName() + " is " + cf.format(e.grossWeeklyPay( hoursWorked )) + "."); Console.printPrompt("Enter data for next employee " + "(quit to end): "); fName = Console.readWord(); } } }