Originally Posted by
John Joe
Why you need array to call method ?
static Employee_3[] employeeArray = new Employee_3[3];
And show your Employee_3 class
This is the Employee_3 class:
package employee_3;
import java.io.Serializable;
import java.util.Scanner;
/**
*
* @author KC
*/
public class Employee_3 implements Serializable
{
private String Name;
public float employeeType;
//
public static int counter;
// added variables
float rate=30.0f;
float taxrate=0.2f;
int hours=45;
float gross=0.0f;
float tax=0.0f;
float net=0.0f;
float net_percent=0.0f;
public Employee_3() //constructor
{
}
public String getName()
{
return Name;
}
public void setName(String s)
{
Name = new String(s);
}
public void setemployeeType(float et)
{
employeeType = et;
}
public void computeGross()
{
gross = rate * hours;
}
protected void computeTax()
{
tax = gross * taxrate;
}
protected void computeNet()
{
net = gross - tax;
}
protected void computeNetperc()
{
net_percent = ( net / gross )* 100;
}
// employee calculations
public void calcMenu()
{
Scanner sc = new Scanner(System.in);
int input;
System.out.println("Please enter your id [first name and last initial]: ");
Name = sc.next();
do
{
System.out.println("0) Calculate Gross");
System.out.println("1) Calculate Tax");
System.out.println("2) Calculate Net");
System.out.println("3) Calculate Net Percent");
System.out.println("4) Display Employee");
input = sc.nextInt();
if(input == 0)
{
computeGross();
}
else if(input == 1)
{
computeTax();
}
else if(input == 2)
{
computeNet();
}
else if(input == 3)
{
computeNetperc();
}
else
{
displayEmployee();
}
}
while(input >= 0 && input <= 4);
}
protected void displayEmployee()
{
System.out.println("Name: " + Name);
System.out.println("Hours: " + hours);
System.out.println("Rate: " + rate);
System.out.println("Gross: " + gross);
System.out.println("Net: " + net);
System.out.println("Net%: " + net_percent + "%");
}
}
//} // end class Employee_3
--- Update ---
Originally Posted by
John Joe
Why you need array to call method ?
static Employee_3[] employeeArray = new Employee_3[3];
And show your Employee_3 class
It was suggested that I use an array