2008-06-21 16:03:43 UTC
/* --Payrollprogram
* myname
* 06/20/08
* payroll/calculation
System.out.print("Enter employee name: ");
employee = Input.readString();
while (employee.equals(""))
{
System.out.print("Enter proper employee name: ");
employee = Input.readString();
continue;
}
// hours worked
while (!hours_valid)
{
System.out.print("How many hours did " + employee + " work? ");
hours = Input.readDouble();
while (hours < 0)
{
System.out.print("Enter proper number of hours: ");
hours = Input.readDouble();
continue;
}
hours_valid = true;
}
// rate
while (!rate_valid)
{
System.out.print("How much does " + employee + " make per hour? ");
rate = Input.readDouble();
while (rate < 0)
{
System.out.print("Enter proper number for rate: ");
rate = Input.readDouble();
continue;
}
rate_valid = true;
}
// compute pay check
double pay = rate * hours;
NumberFormat fmt = NumberFormat.getCurrencyInstance();
System.out.println("\n" + employee + " worked for " + hours
+ " hours at " + fmt.format(rate) + "/hr; paycheck = "
+ fmt.format(pay));
}
}