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
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());
}
Comments
Leave a comment