please write a program in JAVA ,however, can someone do this in BLUEJ program ca
ID: 3788646 • Letter: P
Question
please write a program in JAVA ,however, can someone do this in BLUEJ program cause I don't know how to put it from other programs PLEASE THANK YOI
You will create a Java application that is used to determine a pay check and display the net pay and its details on the screen PayCheck Class fields: hourly Rate, hoursWorked, grossPay, net Pay, federal TaxAmount, state TaxAmount, FICAAmount, lastName, firstName constants: FEDERAL TAX RATE, STATE TAX RATE, FICA RATE. It is up to you to choose the appropriate data type for each field no-args constructor which sets the numeric fields to 0 and the names to "unknown" and the tax constants to 0.15, and 0.07 a second constructor (overloaded) which allows the user to set the initial values of the fields (including the constants). Do not be concerned if the driver will not use this constructor. Methods: setLastName() set FirstName any values less than 5 or set HourlyRate()- do data validation, do not acceptExplanation / Answer
Here is the code for PayCheck.java:
class PayCheck
{
double hourlyRate;
int hoursWorked;
double grossPay;
double netPay;
double federalTaxAmount;
double stateTaxAmount;
double FICAAmount;
String lastName;
String firstName;
public final double FEDERAL_TAX_RATE ;
public final double STATE_TAX_RATE;
public final double FICA_RATE;
public PayCheck()
{
hourlyRate = 0;
hoursWorked = 0;
grossPay = hourlyRate * hoursWorked;
lastName = "Unknown";
firstName = "Unknown";
FEDERAL_TAX_RATE = 0.15;
STATE_TAX_RATE = 0.09;
FICA_RATE = 0.07;
federalTaxAmount = FEDERAL_TAX_RATE * grossPay;
stateTaxAmount = STATE_TAX_RATE * grossPay;
FICAAmount = FICA_RATE * grossPay;
netPay = grossPay - federalTaxAmount - stateTaxAmount - FICAAmount;
}
public PayCheck(double hR, int hW, String lN, String fN, double FTR, double STR, double FR)
{
hourlyRate = hR;
hoursWorked = hW;
lastName = lN;
firstName = fN;
FEDERAL_TAX_RATE = FTR;
STATE_TAX_RATE = STR;
FICA_RATE = FR;
grossPay = hourlyRate * hoursWorked;
federalTaxAmount = FEDERAL_TAX_RATE * grossPay;
stateTaxAmount = STATE_TAX_RATE * grossPay;
FICAAmount = FICA_RATE * grossPay;
netPay = grossPay - federalTaxAmount - stateTaxAmount - FICAAmount;
}
public void setLastName(String lN) { lastName = lN; }
public void setFirstName(String fN) { firstName = fN; }
public void setHourlyRate(double hR)
{
if(hR >= 5 && hR <= 100)
hourlyRate = hR;
grossPay = hourlyRate * hoursWorked;
federalTaxAmount = FEDERAL_TAX_RATE * grossPay;
stateTaxAmount = STATE_TAX_RATE * grossPay;
FICAAmount = FICA_RATE * grossPay;
netPay = grossPay - federalTaxAmount - stateTaxAmount - FICAAmount;
}
public void setHoursWorked(int hW)
{
if(hW >= 0 && hW <= 80)
hoursWorked = hW;
grossPay = hourlyRate * hoursWorked;
federalTaxAmount = FEDERAL_TAX_RATE * grossPay;
stateTaxAmount = STATE_TAX_RATE * grossPay;
FICAAmount = FICA_RATE * grossPay;
netPay = grossPay - federalTaxAmount - stateTaxAmount - FICAAmount;
}
public double getHourlyRate() { return hourlyRate; }
public int getHoursWorked() { return hoursWorked; }
public double getGrossPay() { return grossPay; }
public double getNetPay() { return netPay; }
public double getFederalTaxAmount() { return federalTaxAmount; }
public double getStateTaxAmount() { return stateTaxAmount; }
public double getFICAAmount() { return FICAAmount; }
public String getLastName() { return lastName; }
public String getFirstName() { return firstName; }
public String toString()
{
String output = "";
output += "First name: " + firstName;
output += " Last name: " + lastName;
output += " Hourly Rate: " + hourlyRate;
output += " Hours worked: " + hoursWorked;
output += " Gross pay: " + grossPay;
output += " Net pay: " + netPay;
output += " Federal Tax: " + federalTaxAmount;
output += " State Tax: " + stateTaxAmount;
output += " FICA Amount: " + FICAAmount;
return output;
}
}
And the code for PayCheckDemo.java is:
import java.util.*;
class PayCheckDemo
{
public static void main(String[] args)
{
PayCheck pCheck = new PayCheck();
Scanner sc = new Scanner(System.in);
while(true)
{
System.out.print("Enter the last name: ");
String temp1;
temp1 = sc.nextLine();
pCheck.setLastName(temp1);
System.out.print("Enter the first name: ");
temp1 = sc.nextLine();
pCheck.setFirstName(temp1);
System.out.print("Enter the number of hours worked: ");
int temp2 = sc.nextInt();
pCheck.setHoursWorked(temp2);
System.out.print("Enter the hourly pay rate: ");
double temp3 = sc.nextDouble();
pCheck.setHourlyRate(temp3);
System.out.println(pCheck);
System.out.print("Do you want to read another employee details (Y/N): ");
temp1 = sc.next();
if(temp1.charAt(0) == 'n' || temp1.charAt(0) == 'N')
return;
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.