Answered step by step
Verified Expert Solution
Question
1 Approved Answer
first create a rectangle class then go through the TODO comments for the rectangle class one by one and write code as instructed JAVA do
first create a rectangle class then go through the TODO comments for the rectangle class one by one and write code as instructed
class Main f Lic static void main(String[] args) \{ If TOD0: Create a rectangle object with Lengthe6, width=4, and colorn"red" using the constructor you wrote in Rectangle class. e.g. ( 8 pts) If TODO: invoke printRectangleInfo method on your object. (2pts) // TODO: Change the color of the object using setNewCotor method, to your favorite color. Print out the new color. k.. If your favorite color is the given color use your second favorite cotor*. (4psin) // ToDo: Invoke the calculateperimeter() method and assign it to a variable p. Then print the following statement the perimeter for the rectangle is: plus whatever the permeter is (See example // ToDo: Invoke the calculatePerimeter() method and assign it to a variable p. Then print the following statement the perimeter for the rectangle 1s: plus whatever the permeter is t5ee exasple below) (4pts) If p= yourobject. calculatepermeter(); 1/ System.out.println ("Perimeter for rectangle ist " + p); // TODO: Invoke the getAreal) method and assign it to a variable a. Then print the following statesent the area for the rectangle is plus whatever the area is (4pts) If TODO: Similarly, invoke isASquare method and assign it to variable s of data type bootean. Then print the following statement Is this rectangle a square? The answer is: (4pts) 17. TODO: Create a another rectangle. object with length =5, width=5 and cotorn"blue". Tavoke isASquare If TODO: Croate a another rectangle object with Iength 5 , widtha5 and colorw"btue", Invoke isa5quare method on this object. (bpts) // System. out. irintlnt-Is thas object a square? The answer is: " + object.1sasquare(1): (2pts). If Too0: Create 10 rectangle objects, starting with widthe 1 to width=1e. For every rectangle, If the length should be dooble of width. For every rectangle, print the rectangle info, 1f rectangle perineter and rectangle area fusing nethods). Hint: Use FoR locg! /f The output should look tike the fotlouings If The length of the rectangle is 2, The width is 1 , and the coler is red. 1/ The perineter is 6 , the area is 2 . - Then, go through the TODO comments in maini) method. Write the code for the TODO comments in the main method, be sure to look at the hints and examples, and test your class. (b) D.Run Online (1) E summer fvey Main.java 35: The length of the rectongle is 4 , The wath is 2 , and the color is red. 36, The perineter is 12 , the area is 8 , 37 38 39 49 41 42 43 Z/ Tooo: Create instance variables for length, width and color. Make sure to vse proper access modifier. (6pts) private int length: orivate int width: class Rectangle H, ToDos Create a Rectangle class to the Teft of this connent (2ots) Too0: Create anstance variables for length, width and color, Make sure to use groper acceas twaifier. (6pts) private int length; private int width: private string color: Q. To00: Create a constructor for rectangle that takes if 3 parannters (far laegth, width and cotor). (8pts) public Rectangte (int length, int width, String color) 1 this.1erigth=length JAVA
do the to do comments for me
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