Hey guys, I am trying something different to try and clean this up, but I must be missing something. I am trying to use set and get commands in place of what I have above, so I have changed (starting with employee name) my code to this:
import java.util.Scanner; //uses class Scanner
public class Employee
{
// Employee class has 4 fields
public char eName;
public double rate;
public double hours;
public double result;
// Employee class has one constructor
public Employee()
{ // initialize name of employee
employeeName = "";
}
// sets values
public void setEmployeeName(String eName)
{
employeeName = eName;
}
// get the employee name
public String getEmployeeName()
{
return (eName);
}
// display message
public void displayMessage()
{
Scanner newEname = new Scanner(System.in);
System.out.print("Enter Name: ");
String name = newEname.nextLine();
while (!(name).equalsIgnoreCase("STOP"))
{
Scanner input = new Scanner(System.in);
System.out.print("Enter Employee's Hourly Pay Rate: "); // prompt for rate
rate = input.nextDouble(); // rate input from user.
while (rate <= 0)
{
System.out.print("Rate Must Be Greater Than Zero. Enter Rate: ");
rate = input.nextDouble(); // rate loop from user.
} // End while
System.out.print("Enter Hours Employee Worked This Week: "); // prompt for hours worked
hours = input.nextDouble(); // hours student worked this week.
while (hours <= 0)
{
System.out.print("Hours Worked Must Be Greater Than Zero. Enter Hours: ");
hours = input.nextDouble(); // Hours loop from user
} // End while
result = rate * hours; // figures students salary
System.out.print(name); // display name
System.out.printf("'s salary for the week is %c%.2f\n", '$', result); //display salary
System.out.print("Enter Employee's Name or Enter STOP to Exit: "); // internal loop prompt
name = newEname.nextLine(); //name input from user
} // End While
System.out.print("Ending Program.");
}
}
Now I get the following 3 errors no matter what I try. I think something is wrong with my "employeeName, or eName, but I am at a loss as to what it is.
Any help would be appreciated.
[CODE][Employee.java:15: cannot find symbol
symbol : variable employeeName
location: class Employee
employeeName = "";
^
Employee.java:19: cannot find symbol
symbol : variable employeeName
location: class Employee
employeeName = eName;
^
Employee.java:25: incompatible types
found : char
required: java.lang.String
return eName;
^/CODE]