(Solved) : Question Rectanglejava Code Already Written Need Help File Rectanglewithareajava Q42740714 . . .

Question:

Download the RectangleWithArea.java file, and open it in jGrasp (or a text editor of your choice). You will need to add code

The Rectangle.java code has already been written, hereit is:

public class Rectangle { /DO NOT MODIFY THE INSTANCE VARIABLES // begin instance variables private int width; private int hei

// 7.) Define a method named getPerimeter, which /7 // // TODO returns the perimeter of the rectangle. write your code below

public String toString) { getHeight () ); return Rectangle(+getWidth( )+, } public int getPerimeter() { int perimeter re

I need help with this file,RectangleWithArea.java

// TODO - write your code below this comment. // As a hint, You will need to make RectangleWithArea inherit // from Rectangle

Download the RectangleWithArea.java file, and open it in jGrasp (or a text editor of your choice). You will need to add code to this file so that it compiles and produces the correct output. More details are in the comments in the file. As stated in step 1, this file depends on your from folder/directory. Example output RectangleWithArea.java with the command-line arguments 3 5 is shown below: file being in the Rectangle.java same Width: 3 Height: 5 Area: 15 public class Rectangle { /DO NOT MODIFY THE INSTANCE VARIABLES // begin instance variables private int width; private int height; // end instance variables // You need to do the following: /7 / 1.) Define a constructor which takes two ints // // /7 /7 / 2.) Define a “getter” named getWidth, which returns /7 /7 //3.) Define a “getter” named getHeight, which returns representing the width and height, respectively. The constructor should set its instance variables equal to these values. the width of the rectangle. the height of the rectangle. /7 / 4. Define a “setter” named setWidth, which takes // /7 the new width of the rectangle and sets the rectangle’s width to that value. // 5.) Define a “setter” named setHeight, which // // // // 6.) Define a toString method, which returns // /7 takes the new height of the rectangle and sets the rectangle’s height to that value a String representation of the rectangle. As an example, if the width of the rectangle is // 7.) Define a method named getPerimeter, which /7 // // TODO returns the perimeter of the rectangle. write your code below this comment. public Rectangle(int num1, int num2) { width = numl; height } = num2; public int getWidth() { return width; } public int getHeight(){ return height; } public void setWidth(int newl) { width = newl; public void setHeight(int newl) { height } = newl; public String toString() { public String toString) { getHeight () “)”; return “Rectangle(“+getWidth( )+”, } public int getPerimeter() { int perimeter return perimeter; = 2 (getWidth() + getHeight()); } } 2 (width +height) //perimeter // TODO – write your code below this comment. // As a hint, You will need to make RectangleWithArea inherit // from Rectangle, and you’ll need to use super in the constructor. /DO NOT MODIFY main! public static void main(String args) { RectangleWithArea r = new RectangleWithArea ( Integer.parseInt (args[ 0]), Integer.parseInt (args [1] ) ); r.getWidth() ); r.getHeight()); r.getArea( ) ); System.out.println(“Width: System.out.println( “Height: System.out.println(“Area: Show transcribed image text Download the RectangleWithArea.java file, and open it in jGrasp (or a text editor of your choice). You will need to add code to this file so that it compiles and produces the correct output. More details are in the comments in the file. As stated in step 1, this file depends on your from folder/directory. Example output RectangleWithArea.java with the command-line arguments 3 5 is shown below: file being in the Rectangle.java same Width: 3 Height: 5 Area: 15
public class Rectangle { /DO NOT MODIFY THE INSTANCE VARIABLES // begin instance variables private int width; private int height; // end instance variables // You need to do the following: /7 / 1.) Define a constructor which takes two ints // // /7 /7 / 2.) Define a “getter” named getWidth, which returns /7 /7 //3.) Define a “getter” named getHeight, which returns representing the width and height, respectively. The constructor should set its instance variables equal to these values. the width of the rectangle. the height of the rectangle. /7 / 4. Define a “setter” named setWidth, which takes // /7 the new width of the rectangle and sets the rectangle’s width to that value. // 5.) Define a “setter” named setHeight, which // // // // 6.) Define a toString method, which returns // /7 takes the new height of the rectangle and sets the rectangle’s height to that value a String representation of the rectangle. As an example, if the width of the rectangle is
// 7.) Define a method named getPerimeter, which /7 // // TODO returns the perimeter of the rectangle. write your code below this comment. public Rectangle(int num1, int num2) { width = numl; height } = num2; public int getWidth() { return width; } public int getHeight(){ return height; } public void setWidth(int newl) { width = newl; public void setHeight(int newl) { height } = newl; public String toString() {
public String toString) { getHeight () “)”; return “Rectangle(“+getWidth( )+”, } public int getPerimeter() { int perimeter return perimeter; = 2 (getWidth() + getHeight()); } } 2 (width +height) //perimeter
// TODO – write your code below this comment. // As a hint, You will need to make RectangleWithArea inherit // from Rectangle, and you’ll need to use super in the constructor. /DO NOT MODIFY main! public static void main(String args) { RectangleWithArea r = new RectangleWithArea ( Integer.parseInt (args[ 0]), Integer.parseInt (args [1] ) ); r.getWidth() ); r.getHeight()); r.getArea( ) ); System.out.println(“Width: System.out.println( “Height: System.out.println(“Area:

Expert Answer


Answer to Question: The Rectangle.java code has already been written, here it is: I need help with this file, RectangleWithArea.ja…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us