Answer to Question #325463 in HTML/JavaScript Web Application for Sai

Question #325463

Area and circumference a circle



"use strict";



process.stdin.resume();


process.stdin.setEncoding("utf-8");



let inputString = "";


let currentLine = 0;



process.stdin.on("data", (inputStdin) => {


inputString += inputStdin;


});



process.stdin.on("end", (_) => {


inputString = inputString.trim().split("\n").map((str) => str.trim());


main();


});



function readLine() {


return inputString[currentLine++];


}



/* Please do not modify anything above this line */



function Circle(radius) {



/* Write your code here */



}



/* Please do not modify anything below this line */



function main() {


const radius = JSON.parse(readLine());



const circle1 = new Circle(radius);



console.log(circle1.getArea());


console.log(circle1.getCircumference());


}


Input:7


Output:153.86


43.96

1
Expert's answer
2022-04-07T17:38:00-0400
process.stdin.resume();
process.stdin.setEncoding("utf-8");


let inputString = "";
let currentLine = 0;


process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});


process.stdin.on("end", (_) => {
    inputString = inputString.trim().split("\n").map((str) => str.trim());
    main();
});


function readLine() {
    return inputString[currentLine++];
}


/* Please do not modify anything above this line */


function Circle(radius) {
    return {
        getArea: function() {
            return Math.PI * radius * radius;
        },
        getCircumference: function() {
            return 2 * Math.PI * radius;
        }
    }
}


/* Please do not modify anything below this line */
function main() {
    const radius = JSON.parse(readLine());
    const circle1 = new Circle(radius);
    
    console.log(circle1.getArea());
    console.log(circle1.getCircumference());
}

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