Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PSEUDOCODE: Design JAVA (PSEUDOCODE*) and implement (source code) a program (name it MyRectangle) that defines the following 3 methods: Method isValid() returns true if the

PSEUDOCODE: Design JAVA (PSEUDOCODE*) and implement (source code) a program (name it MyRectangle) that defines the following 3 methods: Method isValid() returns true if the sum of the width and height is greater than 30 Method Area() returns the area of the rectangle if it is a valid rectangle Method Perimeter() returns the perimeter of the rectangle if it is a valid rectangle The main method of MyRectangle prompts the user to enter the width and height of a rectangle and uses MyRectangle methods to print out a message followed by the area and perimeter if the rectangle is valid. Otherwise, it prints out only the message This is invalid rectangle. Try again.. Note that method isvalid() is used to validate the input before attempting to compute the area and perimeter. Document your code and properly label the input prompt and the outputs as shown below. Sample run 1: Entered width: 4 Entered height: 5 This is invalid rectangle. Try again Sample run 2: Entered width: 20 Entered height: 15 Area: 300 Perimeter: 70 Sample run 3: Entered width: 10 Entered height: 5 This is invalid rectangle. Try again. Sample run 4: Entered width: 30 Entered height: 6 Area: 180 Perimeter: 72 Feet Meter 1.0 0.305 2.0 0.610 3.0 0.915 . . . . . . 19.0 5.7.95 20.0 6.100 Meter Feet 1.0 3.279 2.0 6.558 3.0 9.837 . . . . . . 19.0 62.301 20.0 65.574 The program defines the following methods: Method feetToMeter() converts from feet to meter. (formula: meter = 0.305 * feet) Method meterToFeet() converts from meter to feet. (formula: feet = 3.279 * meter) The main method calls these methods to produce the display the output in tabular format. Document your code and format the outputs as Program 1: Design (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the following 3 methods: Method isValid() returns true if the sum of the width and height is greater than 30 Method Area() returns the area of the rectangle if it is a valid rectangle Method Perimeter() returns the perimeter of the rectangle if it is a valid rectangle The main method of MyRectangle prompts the user to enter the width and height of a rectangle and uses MyRectangle methods to print out a message followed by the area and perimeter if the rectangle is valid. Otherwise, it prints out only the message This is invalid rectangle. Try again.. Note that method isvalid() is used to validate the input before attempting to compute the area and perimeter. Document your code and properly label the input prompt and the outputs as shown below. Sample run 1: Entered width: 4 Entered height: 5 This is invalid rectangle. Try again Sample run 2: Entered width: 20 Entered height: 15 Area: 300 Perimeter: 70 Sample run 3: Entered width: 10 Entered height: 5 This is invalid rectangle. Try again. Sample run 4: Entered width: 30 Entered height: 6 Area: 180 Perimeter: 72 above.

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_2

Step: 3

blur-text-image_3

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

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

Exactly what is a merger?

Answered: 1 week ago

Question

=+designing international assignment C&B packages.

Answered: 1 week ago