Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*~Python~* Using the following example... 3 def main(): 4 # Create a circle with radius 1 5 circle1 = Circle() 6 print(The area of the

*~Python~*

Using the following example...

 3 def main(): 4 # Create a circle with radius 1 5 circle1 = Circle() 6 print("The area of the circle of radius", 7 circle1.radius, "is", circle1.getArea()) 8 9 # Create a circle with radius 25 10 circle2 = Circle(25) 11 print("The area of the circle of radius", 12 circle2.radius, "is", circle2.getArea()) 13 14 # Create a circle with radius 125 15 circle3 = Circle(125) 16 print("The area of the circle of radius", 17 circle3.radius, "is", circle3.getArea()) 18 19 # Modify circle radius 20 circle2.radius = 100  # or circle2.setRadius(100) 21 print("The area of the circle of radius", 22 circle2.radius, "is", circle2.getArea()) 23 24 main() # Call the main function 

...Design a class named Rectangle to represent a rectangle. The class contains:

Two data fields named width and height .

A constructor that creates a rectangle with the specified width and height . The default values are 1 and 2 for the width and height , respectively.

A method named getArea() that returns the area of this rectangle.

A method named getPerimeter() that returns the perimeter.

Draw the UML diagram for the class, and then implement the class. Write a test program that creates two Rectangle objectsone with width 4 and height 40 and the other with width 3.5 and height 35.7 . Display the width, height, area, and perimeter of each rectangle in this order.

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions