The formula to calculate the area of a circumference is defined as x = π . R2. Considering to this problem that π = 3.14159:
Calculate the area using the formula given in the problem description.
Input The input contains a value of floating point (double precision), that is the variable R.
And for an input of 2, I should be getting x=12.5664 rounded by one number.
I tried using this simple code, but I couldn't remember what to do with the "cannot convert from double to float" error. It's been half a year since I coded.
package TEST;
import java.util.Scanner;
public class TEST {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// let A be radius
float A = scanner.nextFloat();
float A_2 = A * A;
// let B be Pi
double B = 3.14159;
// let x be circumference
float x = A_2 * B;
System.out.printf("x= %.4f" + x);
}}