Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions