//******************************************************************** // lq5.java Author: Brenneman // // Driver to exercise the use of an array of Hourly objects. // // DO NOT CHANGE THIS FILE! //******************************************************************** import cs1.Keyboard; import java.text.NumberFormat; public class lq5 { //----------------------------------------------------------------- // Creates an array of 5 hourly employees //----------------------------------------------------------------- public static void main (String[] args) { final int EMPLOYEES = 5; Hourly[] staff = new Hourly[EMPLOYEES]; String name; int id; double rate; int hours; //------------------------------------------------------ // loop to read in employee info and store in array. //------------------------------------------------------ for (int i=0; i < EMPLOYEES; i++) { name = Keyboard.readString(); id = Keyboard.readInt(); rate = Keyboard.readDouble(); hours = Keyboard.readInt(); staff[i] = new Hourly (name, id, rate, hours); } //------------------------------------------------------ // loop to write out employees and their pay. //------------------------------------------------------ NumberFormat fmt = NumberFormat.getCurrencyInstance(); for (int i=0; i < EMPLOYEES; i++) System.out.println(staff[i] + "\tPay: " + fmt.format(staff[i].pay()) + "\n"); } }