First you are referencing a non-existent variable in display(). You've declared double deductionFederalTax; in the calculateNetMonthly() yet you are using deductFederalTax in the display() method.
However so, the scope of deductionFederalTax variable is only valid in the calculateNetMonthly() method and cannot be reffered to in the display() method. So, declare deductionFederalTax as a class variable.Also, i propose you do so for the variables in the calculateNetMonthly() method since it seems you will need to reference them in the display() method in the subsequent unconcatenated statements.
The code for deductionFederalTax is as follows:
import java.io.*;
import java.util.*;
/**
* Used to calculate the pay of the full time employees
*
* This class allows the application class to calculate the pay of the
* full time employees by gathering information, performing calculations
* and displaying results.
*
*
* @author
* @version
*/
public class FullTimeEmployee {
// -------------------------------------------------------------------------
// You may add more data members to the following to describe a Casual
// Employee. You may need to remove some data members as well.
// -------------------------------------------------------------------------
//------------------Declare Constants---------------------------------------
/**
* Represents the percentage of the federal tax
*/
private final double FEDERAL_TAX_PERCENT = 0.15;
/**
* Represents the percentage of the health insurance deduction
*/
private final double HEALTH_INSURANCE_PERCENT = 0.05;
/**
* Represents the percentage of the Retirement Savings deduction
*/
private final double RETIREMENT_SAVINGS_PERCENT = 0.12;
/**
* Represents the percentage of the state tax
*/
private final double STATE_TAX_PERCENT = 0.08;
//-------------Declare private variables-----------------------------------
/**
* Represents the name for the employee
*/
private String employeeID;
/**
* Represents the name for the employee
*/
private String employeeName;
/**
* Represents the amount in dollars of the salary for the employee
*/
private int monthlySalary;
/**
* Represents the date of employment
*/
private Date startDate;
private double deductionFederalTax;
/**
* Constructor used to create this object. Responsible for setting
* all of this object's information to their corresponding default values
*/
public FullTimeEmployee(){
this.employeeName = "";
}//end of constructor
//-------------------------------------------------------------------------
//Please complete the following get and set methods
//Some may need to be added or removed.
//-------------------------------------------------------------------------
/**
* Returns the employee's name from this object
* @return String Name of the Employee represented in object
*/
public String getEmployeeName() {
return employeeName;
}
/**
* Sets the employee name represented by this object
* @param employeeName the name of the employee
*/
public void setEmployeeName(String employeeName) {
this.employeeName = employeeName;
}
//--------------------------------------------------------------------------
//Please complete the code and docmentation for the following methods
//--------------------------------------------------------------------------
// --------------------------------------------------------------------------
// In the following, we will just have some "simulated" methods since you do
// do not have enough background to actually implement the following
// behavior. Our calculation is simply to printout a statement "performing"
// an action. You need to perform the actual calculations for this type
// of employee.
// Hint!
// 1. Complete the getInput method. You will need to prompt the user for
// all of the information related to the employee. Use the provided
// readInteger and readString methods within your code to do the actual
// reading or information from the keyboard. Store all of the
// information appropriately.
// 2. Complete the calculateNetMonthly method. You will need to take some
// of the information you have read from the getInput method and do the
// appropriate calculations. You may need to break down this method
// into several seperate methods and/or determine how to store the
// calculated information.
// 3. Complete the display method. You need to print out the information
// that was input or calculated as needed for this employee type.
// --------------------------------------------------------------------------
public void calculateNetMonthly(){
//double deductionFederalTax;
double deductionStateTax;
double deductionRetirementSavings;
double deductionHealthInsurance;
double totalDeduction;
double netMonthlySalary;
deductionFederalTax = (monthlySalary * FEDERAL_TAX_PERCENT);
deductionStateTax = (monthlySalary * STATE_TAX_PERCENT);
deductionRetirementSavings = (monthlySalary * RETIREMENT_SAVINGS_PERCENT);
deductionHealthInsurance = (monthlySalary * HEALTH_INSURANCE_PERCENT);
totalDeduction = (deductionFederalTax + deductionStateTax + deductionRetirementSavings + deductionHealthInsurance);
netMonthlySalary = (monthlySalary - totalDeduction);
}//end of calculateNetMonthly
public void display(){
System.out.println("Calculating Pay for Employee: " + employeeName +" employeeID: " + employeeID);
System.out.println("Deduction for Federal Income Tax (15%): " + deductionFederalTax);
System.out.println("Deduction for State Income Tax (8%): $");
System.out.println("Deduction for Retirement Savings (12%): $");
System.out.println("Deduction for Health Insurance (5%): $");
System.out.println("Total deductions from employee salary: $");
System.out.println("The net monthly salary of the employee is: $");
}//end of display
public void getInput(){
System.out.println("Please enter the Employee ID:");
employeeID = readString();
System.out.println("Please enter the Employee Name:");
employeeName = readString();
System.out.println("Please enter the date of the employement period:");
System.out.println("Please enter the gross salary of employee (in dollars):");
monthlySalary = readInteger();
}//end of getInput
/**
* This method reads an integer and returns it to the caller of the method.
* @return int integer read from keyboard
*/
private int readInteger() {
int temp = 0;
Scanner scanner = new Scanner(System.in);
try {
temp = scanner.nextInt(); // read integer
} catch (InputMismatchException ex) {
System.out.println(ex);
}
return temp;
} // end readInteger
/**
* This method reads a string and returns it to the caller of the method.
* @return String String read from keyboard
*/
private String readString() {
String userInput = "";
Scanner scanner = new Scanner(System.in);
userInput = scanner.nextLine();
return userInput;
} // end readString
//}//end of class FullTimeEmployee
public static void main(String[] args) {
FullTimeEmployee ft=new FullTimeEmployee();
ft.getInput();
ft.calculateNetMonthly();
ft.display();
}
}