i.) Create a class Rectangle that has the length and width instance variables, each of which defaults to 1. Provide methods that calculate the rectangle’s perimeter and area. It has setWidth(),...

i.) Create a class Rectangle that has the length and width instance variables, each of which defaults to 1. Provide methods that calculate the rectangle’s perimeter and area. It has setWidth(), setHighth(), getWidth(), and getHighth() methods for both length and width. Each set method for length and width should verify that length and width are floating-point numbers larger than 0.0 and less than 20.0. Each get method shows the values of length and width. Also, the Rectangle class has calcuatePermeter() and calculateArea() methods. Write a class “TestRectangle to test the class Rectangle. In the TestRectangle, each method of Rectangle class needs to be called with the input entered from screen and display the results.

ii.) Create a class Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. If the monthly salary is not positive, do not set its value and display an error message. Write a class TestEmployee that demonstrates the class Employee. Create two employee objects, and set each employee’s last name, first name, and monthly salary using the input entered from screen and display each employee’s last name, first name, and monthly salary.


e.x.) ii.) Create a class Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. If the monthly salary is not positive, do not set its value and display an error message. Write a class TestEmployee that demonstrates the class Employee. Read the first name, last name and monthly salary of two employees from screen input, create two employee objects using the constructor, and display each employee’s last name, first name, and monthly salary using getFirstName(), getLastName() and getSalary() operations.


May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here