/home/caleb/NetBeansProjects/ADSV Java/lab4_CalebFontenot/src/main/java/com/calebfontenot/lab4_calebfontenot/payroll.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package com.calebfontenot.lab4_calebfontenot;
import java.text.DecimalFormat;
import java.util.Scanner;
@author
public class payroll {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String employeeName;
double hoursWorked;
double hourlyPayRate;
double federalTaxWithholdingRate;
double stateTaxWithholdingRate;
double grossPay;
double federalWithholding;
double stateWithholding;
double totalDeduction;
System.out.print("Enter employee's name: ");
employeeName = input.next();
System.out.print("Enter the number of hours worked in a week: ");
hoursWorked = input.nextDouble();
System.out.print("Enter the hourly pay rate: $");
hourlyPayRate = input.nextDouble();
System.out.print("Enter the federal tax witholding rate (as a decimal, please!): ");
federalTaxWithholdingRate = input.nextDouble();
System.out.print("Enter the state tax withholding rate (as a decimal, please!): ");
stateTaxWithholdingRate = input.nextDouble();
System.out.println("");
DecimalFormat df = new DecimalFormat("#0.00");
grossPay = (hoursWorked * hourlyPayRate);
federalWithholding = (grossPay * federalTaxWithholdingRate);
stateWithholding = (grossPay * stateTaxWithholdingRate);
totalDeduction = (grossPay - (federalWithholding + stateWithholding));
System.out.println("Employee Name: "+employeeName);
System.out.println("Hours Worked: "+hoursWorked);
System.out.println("Pay Rate: $"+ df.format(hourlyPayRate));
System.out.println("Gross Pay: $"+df.format(grossPay));
System.out.println("Deductions:");
System.out.println("\t"+"Federal Withholding ("+ (federalTaxWithholdingRate * 100.0)+"%):$"+df.format(federalWithholding));
System.out.println("\t"+"State Withholding ("+ (stateTaxWithholdingRate * 100.0)+"%):$"+df.format(stateWithholding));
System.out.println("Total Deduction: $"+df.format(totalDeduction));
}
}