Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Theres Many Errors in this Code (Salary) i need help

Java
public class Salary extends Employee
{
	private double salary;//Annual Salary
	public Salary (String name, String address, int number , int double salary)
	{
		super(name,address,number);
		setSalary(salary);
	}
	public void mailCheck()
	{
		System.out println("Within mailCheck of Salary class");
		System.out println("Mailing check to " + getName() + "with salary" + salary);
	}
	public double getSalary() 
	{
		return salary;
	}
	public void setSalary(double newSalary)
	{
		if(newSalary >= 0.0)
		{
			Salary = new Salary;
		}
	}
	public double computePay()
	{
		System.out.println("Computing Salary pay for" + getName());
		return salary/52;
	}
}


What I have tried:

it gives me a head ache in this Code XD
Posted
Updated 23-Sep-18 22:21pm
v2
Comments
Patrice T 23-Sep-18 22:05pm    
"Theres Many Errors in this Code"
And you plan to tell us what errors ?

1 solution

Start by looking at the error messages, and the lines they refer to: probably the first error is on this line:
public Salary (String name, String address, int number , int double salary)
What is an int double? A double is a floating point number, an int is not - you can;t just combine them and hope the system works out what you meant!
Take out the int type and that should remove some errors.
public Salary (String name, String address, int number , double salary)
Then the next I can see is this line:
System.out println("Within mailCheck of Salary class");
Where you have a space between out and println. What do you think should be between them?

LOok at each line it is complaining about and read it carefully - at the moment I suspect you are reading what you meant to write instead of what you actually did. That's easy to do - I do it all the time - but you have to work out what the compiler is talking about, and remember that one error can cause others because the compiler gets "confused" as to what you did mean to write.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900