[Solved] SOLVED:a rectangle class and a driver program.

$25

File Name: SOLVED:a_rectangle_class_and_a_driver_program..zip
File Size: 433.32 KB

SKU: [Solved] SOLVED:a rectangle class and a driver program. Category: Tag:
5/5 - (1 vote)

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 rectangles width and length. Use the methods getLength and getWidth to access these two values 4. Print the rectangles area 5. Print the rectangles perimeter 6. Print the object, which will invoke the toString method 7. Change the rectangles 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.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] SOLVED:a rectangle class and a driver program.
$25