0
I need help with 2Ďr - Write a small program that will calculate and print the perimeter of a circle for you.
My faulty code below: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double pi = 3.14; //your code goes here p = scanner.nextline(); double newVar = p * pi * pi; System.out.println("The perimeter of a circle is: " + newVar); } }
3 Answers
+ 3
Harrison Rogers
Why there is pi * pi ?
Check formula again
2PI doesn't mean PI * PI it is 2 * PI
+ 2
2Ďr means 2 * pi * r
not pi^2 *r
+ 1
Thank you for the help.