Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SHOWS ERROR: /SalaryPaycheck.java:1: error: class, interface, or enum expected SalaryPaycheck.java() ^ 1 error SalaryPaycheck.java import java.util.Scanner; public class SalaryPaycheck { private float grossAmount; private int

SHOWS ERROR:

/SalaryPaycheck.java:1: error: class, interface, or enum expected SalaryPaycheck.java() ^ 1 error

SalaryPaycheck.java

import java.util.Scanner;

public class SalaryPaycheck {

private float grossAmount;

private int employeeId;

private int maritalStatus;

private String employeeName;

// getter and setter

public String getEmployeeName() {

return employeeName;

}

public void setEmployeeName(String employeeName) {

this.employeeName = employeeName;

}

public float getGrossAmount() {

return grossAmount;

}

public void setGrossAmount(float grossAmount) {

this.grossAmount = grossAmount;

}

public int getEmployeeId() {

return employeeId;

}

public void setEmployeeId(int employeeId) {

this.employeeId = employeeId;

}

public int getMaritalStatus() {

return maritalStatus;

}

public void setMaritalStatus(int maritalStatus) {

this.maritalStatus = maritalStatus;

}

// method to calculate NetPay

public void calculateNetPay(float grossAmount,int employeeID,int maritialStatus)

{

float federalIncomeTax = 0;

//it is for single person

if (getMaritalStatus() ==0)

{

// this is for salary less than $2000

if(getGrossAmount()<=2000)

{

federalIncomeTax = (getGrossAmount() * 10)/100;

System.out.println("Federal Income Tax:" +federalIncomeTax);

}

// this is for salary less than $5000 here is some trick as for 2000 we pay 200 tax so added that tax and deducted 2000

//gross salary as this is the way to calculate fedral tax

else if(getGrossAmount()<=5000)

{

federalIncomeTax = 200 + ((getGrossAmount()-2000) * 20)/100;

System.out.println("Federal Income Tax:" +federalIncomeTax);

}

// this is for salary more than $5000 here for 5000 we pay 2000 + 3000 thus tax are 10% of 2000-> 200 and

//20% of 3000 -> 600 all total 200+600 =800 ,added this in tax and removed 5000 from gross salary

else if(getGrossAmount()>5000)

{

federalIncomeTax = 800 + ((getGrossAmount()-5000) * 30)/100;

System.out.println("Federal Income Tax:" +federalIncomeTax);

}

}

// For married person

else

{

//Same operation as done for single

// this is for salary less than $4000

if(getGrossAmount()<=4000)

{

federalIncomeTax = (getGrossAmount() * 10)/100;

System.out.println("Federal Income Tax:" +federalIncomeTax);

}

// this is for salary less than $7000

else if(getGrossAmount()<=7000)

{

federalIncomeTax = 400 + ((getGrossAmount()-4000) * 20)/100;

System.out.println("Federal Income Tax:" +federalIncomeTax);

}

// this is for salary more than $7000

else if(getGrossAmount()>7000)

{

federalIncomeTax = 100 + ((getGrossAmount()-7000) * 30)/100;

System.out.println("Federal Income Tax:" +federalIncomeTax);

}

}

// 3.5 after removing federal income tax

float stateTax = ((getGrossAmount()-federalIncomeTax) * 3.5f)/100;

System.out.println("State Tax:" +stateTax);

//5 % on gross salary

float retirementPlan = (getGrossAmount() * 5)/100;

System.out.println("Retirement Plan:" +retirementPlan);

//6.5% on gross salary

float healthInsurance =(getGrossAmount() * 6.5f)/100;

System.out.println("Health Insurance:" +healthInsurance);

// net Pay after removing all taxes

float netSalary = getGrossAmount() - federalIncomeTax - stateTax - healthInsurance - retirementPlan;

System.out.println("Net Salary:" +netSalary);

}

public static void main(String[] args) {

//user input and function call

SalaryPaycheck spcheck = new SalaryPaycheck();

Scanner sc = new Scanner(System.in);

System.out.println("Enter employee ID");

spcheck.setEmployeeId(sc.nextInt());

System.out.println("Enter employee name");

spcheck.setEmployeeName(sc.next());

System.out.println("Enter employee maritialstatus 0 for single 1 for married");

spcheck.setMaritalStatus(sc.nextInt());

System.out.println("Enter employee GrossSalary");

spcheck.setGrossAmount(sc.nextFloat());

System.out.println("Employee ID :" +spcheck.getEmployeeId());

System.out.println("Gross Amount: $" +spcheck.getGrossAmount());

spcheck.calculateNetPay(spcheck.getGrossAmount(), spcheck.employeeId, spcheck.getMaritalStatus());

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. Explain how business strategy affects HR strategy.

Answered: 1 week ago