Write an application 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 π. 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.
Guide On Rating System
Vote
import java.util.Scanner;
public class CircleCalculations {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the radius of the circle: ");
int radius = sc.nextInt();
System.out.printf("Diameter: %.2f%n", 2 * (double) radius);
System.out.printf("Circumference: %.2f%n", 2 * 3.14159 * radius);
System.out.printf("Area: %.2f%n", 3.14159 * radius * radius);
sc.close();
}
}