Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA - public class CallRectangle { public static void main ( String [ ] args ) { Rectangle myRectangle = new Rectangle ( ) ;

JAVA
-
public class CallRectangle {
public static void main(String[] args){
Rectangle myRectangle = new Rectangle();
myRectangle.setSize(1,4);
if (myRectangle.getArea()!=4){
System.out.println("FAILED getArea() for 1,4");
}
if (myRectangle.getPerimeter()!=10){
System.out.println("FAILED getPerimeter() for 1,4");
}
myRectangle.setSize(2,6);
if (myRectangle.getArea()!=12){
System.out.println("FAILED getArea() for 2,6");
}
if (myRectangle.getPerimeter()!=16){
System.out.println("FAILED getPerimeter() for 2,6");
}
}
}
public class Rectangle {
private int height;
private int width;
public void setSize(int heightVal, int widthVal){
height = heightVal -1;
width = widthVal +1;
}
public int getArea(){
return height * width;
}
public int getPerimeter(){
return (height *2)+(width *2);
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions

Question

What are the disadvantages? L01

Answered: 1 week ago

Question

=+3. Who can provide information for evaluation?

Answered: 1 week ago