Problem with Unexpected Type Error
Hi, I am new to Java (college class) and I am finishing up an assignment. I am down to my last couple of errors but this one has me stumped.
import java.text.NumberFormat;
public class HospitalEmployee
{
private String name;
private double hoursWorked;
private double payRate;
private int number;
final NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();
public HospitalEmployee()
{
name = "Christopher Smith";
payRate = 0.00;
hoursWorked = 0.00;
number = 9999;
}
public String getName()
{
return ("Christopher Smith");
}
public double calculateGrossPay()
{
return calculateGrossPay() = hoursWorked * payRate;
}
public void changeHoursWorked(double hours)
{
hoursWorked = hoursWorked + hours;
}
public void changePayRate(double amount)
{
payRate = payRate + amount;
}
public double calculateBonus(String rating)
{
if (rating.equals("excellent"))
return 500;
else
if (rating.equals("satisfactory"))
return 300;
else
return 0;
}
public String toString()
{
return("Employee: " + getName() + "Employee Number: " + number + " Hours Worked: " + hoursWorked + " Pay Rate: " + currencyFormat.format (payRate) + ".");
}
}
HospitalEmployee.java:27: error: unexpected type
calculateGrossPay() = hoursWorked * payRate;
^
required: variable
found: value
I am totally in the dark as to the problem. Can someone explain this to me and help me with a solution?
Thank you.
Re: Problem with Unexpected Type Error
As stated on the error, you are trying to assign a value on a method which is not valid.
Re: Problem with Unexpected Type Error
And how would I go about fixing that? I have been in this class for just a few weeks so most of this flies miles above my head. : /