Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a class called Rectangle that maintains two attributes to represent the length and width of a rectangle. Provide suitable get, set, and toString

1. Write a class called Rectangle that maintains two attributes to represent the length and width of a rectangle. Provide suitable get, set, and toString methods plus two methods that return the perimeter and area of the rectangle. Include two constructors for this class. One a parameterless constructor that initializes both the length and width to 0, and the second one that takes two parameters to initialize the length and width.

2. Write a java program (a driver application) that tests the above class by providing the users with the following menu options: 1 - to set the length 2 - to set the width 3 - to get the length 4 - to get the width 5 - to get the perimeter 6 - to get the area 7 - to print the object as string 0 - to quit Your program should create one Rectangle object at the beginning using the default constructor, and then repeatedly call the appropriate method for that object depending on the user selection from the above menu. Use JOptionPane for all input/output.

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

What is job enlargement ?

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago

Question

What impediments deal with regulators?

Answered: 1 week ago

Question

What are their performance levels?

Answered: 1 week ago