Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the height and width of a rectangle, you can calculate its area and perimeter. Write a program that prompts the user to enter the

image text in transcribed

Given the height and width of a rectangle, you can calculate its area and perimeter. Write a program that prompts the user to enter the width and the height of two rectangles. The program should then output the area and the perimeter of each rectangle and compare them. You have to define the below three methods: a. area: This method takes as its parameters two double values representing the width and the height of a rectangle and returns its area; Area of a rectangle = height *width. Header of area method: public static double area double h, double w) b. perimeter: This method also takes as its parameters two double values representing the width and the height of a rectangle and returns its perimeter; Perimeter of a rectangle = (height + width) * 2: Header of perimeter method: public static double perimeter(double h, double w) c. compareRectangles: This method takes as its parameters the area of the two rectangles and return true if rectangle 1 is bigger than rectangle 2 and false otherwise. Header of compareRectangles method: public static boolean compareRectangles (double areal, double area2) Sample Runi: Enter height and width of the first rectangle: 4 5 Enter height and width of the second rectangle: 6 9 The area of the first rectangle equals 20 and its perimeter equals 18 The area of the second rectangle equals 54 and its perimeter equals 30 Page 2 of 3

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

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions