Whats the error in this JAVA program?



Write A Program to define a class Employee that is described below:

Data Members: Employee code, name, address and basic salary using parameterized constructor

Member Methods:

a) Assign values to code, name, address and basic salary using parameterized constructor

b) Compute and print net salary by using the calculations given below:

Gross Salary = DA + HRA + Basic Salary; Deductions= PF + IT; Net Salary= Gross –Deductions;

DA = 55% of Basic; HRA = 20% of Basic; PF = Rs.1000; IT = 2% of Gross;

c) Show the calculated details.

_______
class Employee
{
String empcode,name,address;
double basicsalary,netsalary;

Employee(String employee_code,String Name,String Address,double Basic_Salary,double Net_Salary)
{
empcode=employee_code;
name=Name;
address=Address;
basicsalary=Basic_Salary;
netsalary=Net_Salary;
}
void calc()
{
double HRA = 20.0/100* basicsalary;
double DA=55.0/100*basicsalary;
double PF=1000.0;
double gross_sal=basicsalary+HRA+DA;
double IT=20.0/100*gross_sal;
double deductions=PF+IT;

netsalary=gross_sal-deductions;

System.out.println(“Employee Name – “+name);

System.out.println(“Employee Number – “+empcode);

System.out.println(“Address – “+address);

System.out.println(“Basic Salary – Rs. “+ basicsalary);

System.out.println(“House Rent Allowance – Rs. “+HRA);

System.out.println(“Dearness Allowance – Rs. “+DA);

System.out.println(“Provident Fund – Rs. “+PF);

System.out.println(“Gross Salary – Rs. “+gross_sal);

System.out.println(“Income Tax Deduction – Rs. “+IT);

System.out.println(“Deduction – Rs. “+deductions);

System.out.println(“Net Salary – Rs. “+netsalary);
}
public static void min()
{
Employee obj = new Employee(“Rohit Roy”,”66″,”Rainbow Apartments,Banjarahills,500067″,235);
obj.calc();
}
}
__________
whenever i try to compile it.. i get an error saying “cannot find symbol-constructor Employee(java.lang.String,java.String,java.lang.String,int)
Whats the mistake in my program???

3 Replies to “Whats the error in this JAVA program?”

  1. um its basicly telling you that you are trying to make a new Employee object, but that there is no constructor what fits the format you used.
    This line is triggering it:
    Employee obj = new Employee(“Rohit Roy”,”66″,”Rainbow Apartments,Banjarahills,500067″,235);
    This is your problem:
    Employee(String employee_code,String Name,String Address,double Basic_Salary,double Net_Salary)
    {
    empcode=employee_code;
    name=Name;
    address=Address;
    basicsalary=Basic_Salary;
    netsalary=Net_Salary;
    }
    As far as the problem I think this may fix it:
    Employee obj = new Employee(“Rohit Roy”,”66″,”Rainbow Apartments”,”Banjarahills”,500067,235);


  2. this line is the problem:

    Employee obj = new Employee(“Rohit Roy”,”66″,”Rainbow Apartments,Banjarahills,500067″,235);

    because, since you defined the constructor like this

    Employee(String, String, String, double, double)

    so u need to pass 3 Strings and 2 doubles

    the problem is that you have surrounded the address and basic salary inside double qoutes “”

    “Rainbow Apartments,Banjarahills,500067” < ----so when testing, you are passing 3 String args and ONLY 1 double args. so re-write the line as:new Employee("Rohit Roy","66","Rainbow Apartments,Banjarahills",500067,235); ----------------------- one more thing is that your main method is defined incorrectly, it should bepublic static void main(String[] args) NOT >> public static void min()


  3. Hi, hotspotgal

    There are 3 step to repair java program error

    If you got java program error then there is a 94% chance that your computer has registry problems. You should fix it immediately. The following software is a professional fix java program error, in addition, you can fix many common computer errors. I think you should try it, I believe that it can help you:

    * Step 1 – Download a java program error repair tool,install this error repair tool.
    * Step 2 – Open the java program error repair tool and scan you computer for free
    * Step 3 – Then click the Repair All Button again and your done!

    Here are the url of java program error repair tool:http://www.RepairErrorSafe.com/ttfix-java_program_error-zz0001





Leave a Reply

Your email address will not be published. Required fields are marked *