In: Computer Science
2.26 Homework 2-3 Write a program that prompts the user for a double value representing a radius. You will use the radius to calculate: circleCircumference = 2πr circleArea = Unknown node type: sup πrUnknown node type: sup sphereArea = Unknown node type: sup 4πrUnknown node type: sup sphereVolume = Unknown node type: sup 43πrUnknown node type: sup You must use π as defined in the java.lang.Math class. Your prompt to the user to enter the number of days must be: Enter radius: Your output must be of the format: Circle Circumference = circleCircumference Circle Area = circleArea Sphere Area = sphereArea Sphere Volume = sphereVolume Please make sure to end each line of output with a newline. Please note that your class should be named CircleSphere.
import java.util.Scanner; public class CircleSphere { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double r; System.out.print("Enter radius: "); r = scanner.nextDouble(); double circleArea = Math.PI*Math.pow(r,2); double circleCircumference = 2*Math.PI*r; double sphereArea = 4*Math.PI*Math.pow(r,2); double sphereVolume = (4.0/3)*Math.PI*Math.pow(r,3); System.out.println("Circle Circumference = "+(circleCircumference)); System.out.println("Circle Area = "+(circleArea)); System.out.println("Sphere Area = "+(sphereArea)); System.out.println("Sphere Volume = "+(sphereVolume)); } }