Reference no: EM13694961
Question: Write an application (CalcCircumference) that inputs from the user the radius of a circle as an integer and prints the circle's diameter, circumference and area using the floating-point value 3.14159 for ?.
[Note: You may also use the predefined constant Math.PI for the value of ?.
This constant is more precise than the value 3.14159. Class Math is defined in package java.lang. Classes in that package are imported automatically, so you do not need to import class Math to use it.]
Use the following formulas (r is the radius):
diameter = 2r
circumference = 2?r
area = ?r2
Do not store the results of each calculation in a variable. Rather, specify each calculation as the value that will be output in a System.out.printf statement.
[Note: that the values produced by the circumference and area calculations are floating-point numbers. Such values can be output with the format specifier %f in a System.out.printf statement.]
Hints:
- For this exercise, output all floating-point values using the %f format specifier.
- System.out.printf( "Area is %f\n", ( Math.PI * radius * radius ) );
Sample Output:
Enter radius: 3
Diameter is 6
Area is 28.274334
Circumference is 18.849556
I cannot seem to get this to work for some reason could somebody provide me a code to compare and test? This one is complex and I don't know how to do it