Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Circle Perimeter and Area
- Write a program that reads the radius r of a circle and prints its perimeter and
- area formatted with 2 digits after the decimal point.
- Examples:
- r perimeter area
- 2 12.57 12.57
- 3.5 21.99 38.48
- */
- // Vladi code
- function solve(input){
- // radius
- let pr = +input[0];
- let radius = Math.PI * pr * pr;
- console.log(radius.toFixed(2));
- // perimeter
- let perimeter = Math.PI * 2 * pr;
- console.log(perimeter.toFixed(2));
- }
- solve(['2'])
- //----------------------------
- // Evo code
- //get data from judge-a тук
- let input = [
- '3.5'
- ];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- // до тук бат Влади
- let radius = Number(gets());
- let perimeter = (2 * Math.PI * radius).toFixed(2);
- let area = (Math.PI * (Math.pow(radius, 2))).toFixed(2);
- print(perimeter);
- print(area);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement