// Exercise 4.14 Solution // GrossPay.java // Programmer: Ken Geddes // This application calculates the gross pay for three employees. import javax.swing.*; public class GrossPay { public static void main( String[] args ) { for (int employee = 1; employee <= 3; employee++) { float hoursWorked = Float.parseFloat(JOptionPane.showInputDialog( "Enter number of hours worked for employee #" + employee + ":" )); float hourlyRate = Float.parseFloat(JOptionPane.showInputDialog( "Enter hourly rate for employee #" + employee + ":" )); float grossPay = hoursWorked * hourlyRate; if (hoursWorked > 40) { grossPay += (hoursWorked - 40) * hourlyRate / 2.0f; } String result = "Employee: " + employee + "\nGross pay this week: $" + grossPay; JOptionPane.showMessageDialog(null, result, "Gross Pay", JOptionPane.INFORMATION_MESSAGE ); } // for System.exit( 0 ); } // main } // GrossPay