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); } }

7th Feb 2022, 5:43 PM
Harrison Rogers
Harrison Rogers - avatar
3 Respostas
+ 3
Harrison Rogers Why there is pi * pi ? Check formula again 2PI doesn't mean PI * PI it is 2 * PI
7th Feb 2022, 5:49 PM
A͢J
A͢J - avatar
+ 2
2πr means 2 * pi * r not pi^2 *r
7th Feb 2022, 6:07 PM
Shaurya Kushwaha
+ 1
Thank you for the help.
8th Feb 2022, 2:58 PM
Harrison Rogers
Harrison Rogers - avatar