
Task
Write two function for the following instructions:
getArea(length, width)
: Calculate and return the area of a rectangle having sideslength andwidth.getPerimeter(length, width)
: Calculate and return the perimeter of a rectangle having sideslength andwidth.
The values returned by these functions are printed to stdout by locked stub code in the editor.
Constraints
- 1 ≤ length, width ≤ 1000
- length andwidth are scaled to at most three decimal places.
Input Format
getArea(length, width)
:
Data Type | Parameter | Description |
---|---|---|
Number | length | A number denoting the length of rectangle. |
Number | width | A number denoting the width of rectangle. |
getPerimeter(length, width)
:
Data Type | Parameter | Description |
---|---|---|
Number | length | A number denoting the length of rectangle. |
Number | width | A number denoting the width of rectangle. |
Output Format
Function | Return Type | Description |
---|---|---|
getArea(length, width) | Number | The area of a rectangle having sideslength andwidth. |
getPerimeter(length, width) | Number | The perimeter of a rectangle having sideslength andwidth. |
Sample
Input
34.5
Output
13.515
Explanation
- The area of the rectangle islength x width = 3 x 4.5 = 13.5.
- The perimeter of the rectangle is2 x (length + width) = 2 x (3 + 4.5) = 15.
Solution
Connect
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse