Write a testprogram that creates two rectangle objects

Assignment Help Computer Engineering
Reference no: EM132112733

Following the example of the Circle class in Section7.2, design a class named Rectangle to represent a rectangle. The classcontains: ¦ 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 testprogram that creates two Rectangle objects-one 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.

7.2

import math

2

3 class Circle:

4 # Construct a circle object

5 def __init__(self, radius = 1 ):

6 self.radius = radius

7

8 def getPerimeter(self):

9 return2 * self.radius * math.pi

10

11 def getArea(self):

12 return self.radius * self.radius * math.pi

13

14 def setRadius(self, radius):

15 self.radius = radius

Reference no: EM132112733

Questions Cloud

Calculate a customers monthly water bill : The program should calculate and display the number of gallons of water used and the total charge for the water.
Parallel implementations - program for a pizza shop : Parallel Implementations - program for a pizza shop - creating the same application in the given programming languages
Write a statement that associates a new value : Write a statement that associates a new value with the first element of the list. The new value should be equal to twice the value of the last element.
Create a dictionary entry with the number : Write a program, dCount(lst,n), which will take a 2-dimensional list which consists of a number (lst[i][0]) and string (lst[i][1]).
Write a testprogram that creates two rectangle objects : Write a testprogram that creates two Rectangle objects-one with width 4 and height 40 and the other with width 3.5 and height 35.7 .
Write a program that uses all of your functions : Write a program that uses all of your functions from above to carry out an RSA key generation, encryption, and decryption.
How could welfare programs exacerbate the problems : How could welfare programs exacerbate the problems they are supposed to cure? The response must be typed, single spaced, must be in times new roman font.
Explain the role of design patterns in the game : Provide a demonstration of the game - how the game play works and how this was implemented - Explain the role of design patterns in the game
What are some examples of in-kind transfers : What are some examples of in-kind transfers? Why do some people prefer that the government provide cash payments to the needy instead of in-kind transfers?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Explain the major benefits for the individuals and society

Describe the influence and effects of Artificial Intelligence on domain. Explain the major benefits for the individuals and society that AI has on each domain.

  Explain the difference between the http actions get and post

Explain the difference between the HTTP actions GET and POST. Which is more vulnerable to SQL injections? Provide an example to support your statement.

  Compare and contrast sdlc and two other development models

Compare and contrast SDLC and 2 other development models. What differences or similarities do you see between your posting and other classmates' postings?

  Describe the two basic methods of attacking locks

Describe the two basic methods of attacking locks. What do you think should dictate the physical nature of a vault?

  Create a memo for the sales meeting as shown

Create a memo for the sales meeting as shown in Figure 1, using the following format. The sales figures should be in Currency cell style with no decimal places.

  What is best combination of furniture cabinets to be made

A furniture cabinet maker produces two types of cabinets that house and hide plasma televisions. What is the best combination of furniture cabinets to be made?

  Prepare a business report comparing the three vendors

A list of the antivirus and firewall packages you researched. You should research and list at least three different antivirus and firewall packages.

  Write a ruby program that reads a line from the user

In class assignments #12. Design a Ruby class that inherits from the inbuilt String class and adds an additional functionality to check if the string is a palindrome. Email your code by end of day 02/28.

  Write a program that swaps the elements of an array pairwise

Write a program that swaps the elements of an array pairwise. Start from the left of the array, take 2 elements at a time and swap the two elements. Continue in this fashion until you reach the end of the array.

  Give an illustration in which polymorphism would be helpful

write a 200- to 300-word short-answer response to the followingprovide an example in which polymorphism would be

  What may cause the loss of one control file

Why must a business have its database in ARCHIVELOG mode?

  How many ways a committee of 4 people can be choosen

The question of how various ways a committee of 4 people can be selected from a group of 10 is known as a combination. The notation in general for counting the number of ways of selecting r items from a group of n is C(n,r) = n! / r!(n-r)!

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd