Question: Programming Challenge 2 (30 points): List and explain the Errors in the following program. Then submit the correct .java program. public class square { private

Programming Challenge 2 (30 points):

List and explain the Errors in the following program. Then submit the correct .java program.

public class square

{

private int sideLength;

private int area;

public Square(int initialLength)

{

sideLength = initialLength;

area = sideLength * sideLength;

}

public int area(){ return area;}

public void grow(){ sideLength = 2* sideLength;}

}

Programming Challenge 2 (50 points):

Implement a class Employee. An employee has a name (a string) and a salary (a double). (5 points)

Provide a constructor with two arguments (10 points)

public Employee(string employeeName, double currentSalary) and methods (15 points)

public String getName() public double getSalary() public void raiseSalary(double byPercent)

These methods return the name and salary, and raise the employees salary by certain percentage.

Sample usage:

Employee harry = new Employee(Hacker, Harry, 5000); Harry.raiseSalary(10); //Harry gets a 10 percent raise

Supply an EmployeeTester class that tests all methods. (15 points)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!