Answer to Question #261446 in HTML/JavaScript Web Application for swsq

Question #261446

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-11-06T18:56:57-0400
function AreaCircumference(radius) {
 this.radius = radius;

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

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

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

const ​radius1 = new AreaCircumference(7);
const ​radius2 = new AreaCircumference(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