Hi everyone,
I am new to Java. I am taking a Java programming course and I am having some difficulty. My professor said I should seperate my class that stores employee information and calculates pay from the class that contains my main method. How do I do that? I understand what the professor is saying and I understand how to create the classes but I am confused on where exactly how to do this. I am going to post some of my code, I know that the employee information class needs to be seperated somewhere in the section of code that I am posting but unsure as to where.
public class Payrollprogram
{
// main method begin program execution
public static void main( String args[] )
{
// scanner to obtain user input
Scanner input = new Scanner( System.in );
}
private String employeeName; //name of employee
//constructor to initialize employeeName
public Payrollprogram( String name )
{
employeeName = name; //initializes employeeName
} //end constructor
// method to set employee name
public void setEmployeeName( String name )
{
employeeName = name;
}// end method setEmployeeName
// method to retrieve employee name
public String getEmployeeName()
{
return employeeName;
} // end method getEmployeeName
//display welcome message for user
public void displayMessage()
}
This is not all of my code but I closed it so that everyone would know that was not the problem.
I have worked on it since my professor last saw it but I'm not sure I fixed the problem he said I was having. Any feed back would be greatly appreciated. I hope I posted the code correctly according to the rules. Thank you.
Sincerely,