package assignmentproject1;
/* CHANGE (FINAL) VAR NAMES, SCAN & VERIFY,
ORGANIZE AND PUT FORMULAS ON BOTTOM, ORGANIZE VAR @ TOP, */
import java.util.*;
public class Project1
{
public static void main (String[] args)
{
Scanner stdin = new Scanner (System.in);
final int OVERTIMEHOURS = 40;
final double FEDTAX = 0.25, CALITAX = 0.09075, SS_MEDI_FICA = 0.0765,
UEIDI = 0.02, OVERTIMEMULTIPLIER = 1.5;
double fedtax, ss_medi_fica, grossPay, rate, totalcost_to_Employer,
calitax, netPay, hours, ueidi, employerFICA;
boolean overtime = false;
//Inputs rate and hours, then calculates the gross pay.
System.out.print ("Enter hourly rate in dollars and cents --> ");
rate = stdin.nextDouble ();
while (rate > 0)
{
System.out.print ("Enter number of hours and tenths worked --> ");
hours = stdin.nextDouble ();
System.out.println ();// LINE SPACER
System.out.println (" PAYROLL REPORT");
System.out.printf ("Rate:%38.2f \n",rate);
System.out.printf ("Hours:%37.1f \n",hours);
grossPay = rate * hours; //calculates gross pay.
fedtax = grossPay * FEDTAX; //calculates federal tax.
calitax = grossPay * CALITAX; //calculates state (CA) tax.
ss_medi_fica = grossPay * SS_MEDI_FICA; //employee pays for FICA.
ueidi = grossPay * UEIDI;
employerFICA = grossPay * SS_MEDI_FICA; //employer pays for FICA.
netPay = grossPay - (fedtax + CALITAX + SS_MEDI_FICA);
totalcost_to_Employer = grossPay + employerFICA
+ ueidi;
//CHECKS CONDITION
System.out.println ();// LINE SPACER
if (hours > 40)
{
overtime = true;
grossPay = rate * OVERTIMEHOURS + (hours - OVERTIMEHOURS)
* (rate * OVERTIMEMULTIPLIER);
fedtax = grossPay * FEDTAX; //calculates federal tax.
calitax = grossPay * CALITAX; //calculates state (CA) tax.
ss_medi_fica = grossPay * SS_MEDI_FICA; //employee pays for FICA.
ueidi = grossPay * UEIDI;
employerFICA = grossPay * SS_MEDI_FICA; //employer pays for FICA.
netPay = grossPay - (fedtax + CALITAX + SS_MEDI_FICA);
totalcost_to_Employer = grossPay + employerFICA
+ ueidi;
System.out.printf ("Gross Pay: %32.2f ", grossPay);
System.out.print (" includes overtime\n");
}
else
{
grossPay = rate * hours;
System.out.printf ("Gross Pay: %32.2f \n", grossPay);
}
System.out.printf ("Federal Tax: %30.2f \n", fedtax);
System.out.printf ("State Tax: %32.2f \n", calitax);
System.out.printf ("FICA: %37.2f \n", ss_medi_fica);
System.out.printf ("Net Pay: %34.2f \n", netPay);
System.out.println ();
System.out.printf ("Employer's FICA contribution: %13.2f \n",
employerFICA);
System.out.printf ("Employer's UEI and DI contribution: %7.2f \n",
ueidi);
System.out.printf ("Cost to Employer: %25.2f \n",
totalcost_to_Employer);
System.out.println();//line spacer
System.out.print ("Enter hourly rate in dollars and cents --> ");
rate = stdin.nextDouble ();
overtime = false;/*have to reset overtime,
so it doesn't apply to regular hours*/
}//end of while loop
}//end main
}//end class