Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Im having a little trouble with this question. Here are the instructions. Desing a class named Rectangle to represent a rectangle. The class contains the

Im having a little trouble with this question. Here are the instructions.

Desing a class named Rectangle to represent a rectangle. The class contains the following:

1. Two data fields named width and height

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

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

4. A method named getPerimeter() that returns the perimeter.

write and test a program (in the same file as the class) that creates two rectangle objects one with width 3 and height 30 and the other with width 3.7 and height 35.5 display the width, height, area, and perimeter of each rectangle in this order

Here is what I have so far but I dont know how to do the second part with the width of 3 and height of 30.

import math class Rectangle: def __init__(self, height = 1, width = 2): self.height = height self.width = width def getArea(self): return self.height * self.width def getPerimeter(self): return (2*self.height)+(2*self.width) myRectangle = Rectangle() yourRectangle = Rectangle() print("the area of myRectangle is", myRectangle.getArea(), "and the perimeter is", yourRectangle.getPerimeter())

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

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago