Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can anyone help me with this? Just need to finish the TO-DO parts' /** * Rectangle.java This class should take width and height as inputs
Can anyone help me with this? Just need to finish the TO-DO parts'
/** * Rectangle.java This class should take width and height as inputs and * calculate the area of a rectangle. * * @author Yi * */ public class Rectangle { // TODO Create private data members for width, height and area. // TODO Create constructor. // TODO Complete the method setWidth() to read width from user. public void setWidth() { } // TODO Complete the method setHeight() to read height from user. public void setHeight() { } // TODO Complete the method computeArea() to compute the area of the // rectangle. public void computeArea() { } // TODO Create a method to compute the perimeter of the rectangle. // TODO Create a getter method to return the rectangle's area. }
/** * RectangleTest.java Driver class that creates a rectangle object and * calculates its perimeter and area. * * @author Yi * */ public class RectangleTest { // Main method public static void main(String[] args) { // TODO Create an instance of Rectangle class. // TODO Set both width and height of the rectangle by calling the methods. // TODO Call computeArea() in Rectangle class. // TODO Call computePerimeter() in Rectangle class. // TODO Output the area and the perimeter. } }
/** * CompareAreas.java * This class creates a circle and a rectangle and compare their areas. * This class should not contain any calculations but only method calls. * @author Yi * */ public class CompareAreas { public static void main(String[] args) { // TODO Create a Circle object. // TODO Set the radius. // TODO Calculate circle area. // TODO Create an instance of Rectangle class. // TODO Set both width and height of the rectangle. // TODO Calculate rectangle area. // TODO Get area for circle. // TODO Get area for rectangle. // TODO Compare two areas and print out results. } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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