Results 1 to 4 of 4
  1. #1
    blessed07 is offline Member
    Join Date
    Jan 2010
    Posts
    7
    Rep Power
    0

    Smile cannot find symbol contructor

    import java.text.*;
    public class Employee {
    private String name;
    private double salary;
    private double bonus;
    private double tax;

    public Employee( String name, double salary) {
    setSalary(name,salary);
    }
    private void setSalary(String n, double sly){
    name = n;
    salary = sly;
    }

    public String getName() {
    return name;
    }
    public double getSalary() {
    return salary;
    }
    public double getBonus() {
    return bonus;
    }
    public double getTax() {
    return tax;
    }
    public double getTotal() {
    return salary*(bonus/100)*((100-tax)/100);
    }
    public String toString() {
    return "\n\nName - " + getName() +
    "\nSalary - " + getSalary() +
    "\nBonus - " + getBonus() +
    "\nTax - " + getTax() +
    "\nSalary - " + getSalary();
    }
    }

    public class EmployeeTest {
    public static void main (String args [] ) {
    Employee myEmployee = new Employee();
    myEmployee.setName("Choo Lee Lee");
    myEmployee.setSalary(5000);
    System.out.println( name + "'s is RM" + salary );
    myEmployee.setBonus(10);
    System.out.println( "The bonus is " + bonus + "%" );
    myEmployee.setTax(5);
    System.out.println( "The tax is " + tax + "%" );
    System.out.println( "The final salary of " + name + " is RM" + total);
    }
    }

    can someone please check for me why the red part was under the error "cannot find symbol constructor Employee()".
    Thanks
    I am a beginner.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    812
    Rep Power
    6

    Default

    You are having constructor which accepts parameters.But,you are trying to call without passing any value.Thats why the error.
    Ramya:cool:

  3. #3
    blessed07 is offline Member
    Join Date
    Jan 2010
    Posts
    7
    Rep Power
    0

    Default

    Thank you very much.
    Then what should i do.
    I am very blur.
    Please guide me.
    Thanks

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    812
    Rep Power
    6

    Default

    u pass name and salary to Employee class constructor instead of setting in setter method
    Ramya:cool:

Similar Threads

  1. cannot find symbol constructor
    By daud in forum New To Java
    Replies: 9
    Last Post: 08-13-2009, 03:53 AM
  2. cannot find symbol
    By GabWit in forum New To Java
    Replies: 3
    Last Post: 01-25-2009, 12:13 AM
  3. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  4. Replies: 3
    Last Post: 05-01-2008, 08:30 AM
  5. Error: cannot find symbol
    By silvia in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:39 AM

Posting Permissions

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