//homework 4.14 GrossPay.java
//Determine the gross pay for each of three employees
//Java extension packages
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class GrossPay{
public static void main(String args[])
{
String hours,rate;
int num=0,h;
double pay=0,sum=0,r;
DecimalFormat twoDigits=new DecimalFormat("0.00");
hours=JOptionPane.showInputDialog("Enter the number of hours each employee worked and -1 to quit:");
h=Integer.parseInt(hours);
while(h!=-1)
{
rate=JOptionPane.showInputDialog("Enter the hourly rate of each employee:");
r=Double.parseDouble(rate);
if(h>40)
pay=(1.5*h-20)*r;
else
pay=h*r;
num++;
sum+=pay;
if(num==3)
{
JOptionPane.showMessageDialog(null,"The gross pay of the three employees is "+twoDigits.format(sum));
num=0;
sum=0;
hours=JOptionPane.showInputDialog("Enter the number of hours each employee worked and -1 to quit:");
h=Integer.parseInt(hours);
}
else
{
hours=JOptionPane.showInputDialog("Enter the number of hours each employee worked and -1 to quit:");
h=Integer.parseInt(hours);
}
}//end while
}//end method
}//end class
//Determine the gross pay for each of three employees
//Java extension packages
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class GrossPay{
public static void main(String args[])
{
String hours,rate;
int num=0,h;
double pay=0,sum=0,r;
DecimalFormat twoDigits=new DecimalFormat("0.00");
hours=JOptionPane.showInputDialog("Enter the number of hours each employee worked and -1 to quit:");
h=Integer.parseInt(hours);
while(h!=-1)
{
rate=JOptionPane.showInputDialog("Enter the hourly rate of each employee:");
r=Double.parseDouble(rate);
if(h>40)
pay=(1.5*h-20)*r;
else
pay=h*r;
num++;
sum+=pay;
if(num==3)
{
JOptionPane.showMessageDialog(null,"The gross pay of the three employees is "+twoDigits.format(sum));
num=0;
sum=0;
hours=JOptionPane.showInputDialog("Enter the number of hours each employee worked and -1 to quit:");
h=Integer.parseInt(hours);
}
else
{
hours=JOptionPane.showInputDialog("Enter the number of hours each employee worked and -1 to quit:");
h=Integer.parseInt(hours);
}
}//end while
}//end method
}//end class