Question
I need some help on a java program: This exercise guides you through the process of converting an Area and Perimeter application from a procedural
I need some help on a java program:
This exercise guides you through the process of converting an Area and Perimeter application from a procedural application to an object-oriented application. Createand use an object 1.Open the project named ch04_ex2_Area and Perimeterthats stored in the ex_starts folder.Then, review the code for the Main class. 2. Create a class named Rectangle and store it in the murach.rectangle package. 3. In the Rectangle class, add instance variables for length and width. The, code the get and set methods for these instance variables. If possible, use your IDE to generate the get and set methods. With NetBeans, you can get started by selecting the RefactorEncapsulate Fields command. 4. Add a zero-argument constructor that initializes the length and width to 0. 5. Add a get method that calculates the area of the rectangle and returns a double value for the result. If you want, you can copy the code that performs this calculation from the Main class. 6. Add a get method that returns the area as a String object with standard numeric formatting and a minimum of three decimal places. To make it easy to refer to the NumberFormat class, you should add an import statement for it. 7. Repeat the previous two steps for the perimeter. 8. Open the Main class. Then, add code that creates a Rectangle object and sets its lengthand width. 9. Modify the code that displays the calculations so it uses the methods of the Rectangle object to get the area and perimeter of the rectangle. 10. Remove any leftover code from the Main class thats unnecessary including any unnecessary import statements. 11. Run the application and test it with valid data. It should calculate the area and perimeter for a rectangle.Overload the constructor 12. Open the Rectanble class. Then, overload the constructor by supplying a second constructor that accepts two arguments: length and width. This constructor should set the length and width of the rectangle to the values supplied by these arguments. 13. Open the Main class. Then, modify its code so it uses this constructor instead of the zero-argument constructor. 14. Run the application and test it to make sure it still works correctly.
Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started