5 width of the square

joshng Reply 7 years 28 weeks ago
import java.util.Scanner; import java.lang.*; public class Main { public static void main(String[] args) { final double PI = 3.14159; Scanner input = new Scanner(System.in); double r = input.nextDouble(); double S = 2 * r * Math.sin(PI/5); double Area = (5 * Math.pow(S, 2.0)) / (4 * Math.tan(PI / 5)); System.out.printf("% 1.2f", + Area); } } I was wondering why the website wouldnt accept this code, can someone give me a suggestion?
chunghee Reply 7 years 28 weeks ago
Suggestion #1 Apply double literal(.0) to all decimals. (ex. use 2.0 * r instead of 2 * r) #2 Math.PI vs 3.14159 #3 I don't understand why you wrote whitespace after %. And you must add new line character (\n) at the end of the line. Good luck.