SOLVED:a rectangle class and a driver program.

29.99 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


5/5 - (4 votes)

Program 1 In this assignment you will write a rectangle class and a driver program. You are supplied with a skeleton of the rectangle class, and you are expected to add code to the skeleton to fulfill the requirements as specified in the comments of the skeleton. (Note: the skeleton source code file does not compile as distributed, it is missing statements that you must add in order to compile) Next you will write a driver program in a separate file which includes the following (be sure to do exactly what is requested in the way it is requested): 1. A main method 2. Create an object of Rectangle called “box” using the constructor that includes two arguments, length and width, setting the length and width to 5 and 15 3. Print the rectangle’s width and length. Use the methods getLength and getWidth to access these two values 4. Print the rectangle’s area 5. Print the rectangle’s perimeter 6. Print the object, which will invoke the toString method 7. Change the rectangle’s width to 20 and length to 5 using the set methods 8. Print the object to verify that the changes took effect Program 2 In one file create an Employee class as per the following specifications: 1. three private instance variables: name (String), startingSalary (int), yearlyIncrement (int) 2. a single constructor with three arguments: the name, the starting salary, and the yearly increment. In the constructor, initialize the instance variables with the provided values. 3. get and set methods for each of the instance variables. 4. A computation method, computeCurrentSalary, that takes the number of years in service as its argument. The method returns the current salary using the calculation: startingSalary + years * yearlyIncrement In a separate file, create a driver as follows: · In the main method, create two Employee objects: Alice with a starting salary of 50000 and a yearly increment of 1000 and Bob with a starting salary of 40000 and a yearly increment of 2500. Write a loop to display the current salaries of the two employees at the end of years 1 through 10. A sample output is shown below.