Answer to Question #175460 in HTML/JavaScript Web Application for prathyusha

Question #175460

Area and Circumference of a Circle

Given radius

radius of a circle, write a JS constructor function with the methods getArea and getCircumference to calculate the area and circumference of the circle.

Note

The value of π = 3.14


Quick Tip

Use the formulae to calculate,

  • Area of circle = π * radius * radius
  • Circumference of circle = 2 * π * radius

Input

  • The input will be a single line containing a number radius

Output

  • The first line of output should contain the area of the circle
  • The second line of output should contain the circumference of the circle

Sample Input 1

7

Sample Output 1

153.86

43.96

Sample Input 2

25

Sample Output 2

1962.5

157




1
Expert's answer
2021-03-27T06:52:48-0400
function GivenRadius(radius) {
    this.radius = radius;

    this.getArea = () => console.log(3.14 * radius ** 2);

    this.getCircumference = () => console.log(2 * 3.14 * radius);

    this.getArea();
    this.getCircumference();
}

const rad = new GivenRadius(7);
const circle = new GivenRadius(25);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS