Results 1 to 3 of 3
  1. #1
    Emo
    Emo is offline Member
    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0

    Default 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.

  2. #2
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default 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.

  3. #3
    Emo
    Emo is offline Member
    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0

    Default 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. : /

Similar Threads

  1. unexpected type on a subtraction sign?
    By JanieRae in forum New To Java
    Replies: 5
    Last Post: 04-22-2010, 05:09 AM
  2. Error: unexpected type
    By silvia in forum New To Java
    Replies: 3
    Last Post: 02-05-2010, 10:54 PM
  3. SwiffChart: Unexpected error in acknowledgement
    By sunil.mact in forum Advanced Java
    Replies: 5
    Last Post: 02-25-2009, 01:33 PM
  4. unexpected type
    By one in forum New To Java
    Replies: 13
    Last Post: 01-20-2009, 10:32 AM
  5. Unexpected Error
    By Mir in forum New To Java
    Replies: 10
    Last Post: 07-07-2008, 08:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •