Use Math class to calculate
- by LC
Write a JAVA program that calculates the surface area of a cylinder, C= 2( p r2) + 2 p r h, where r is the radius and h is the height of the cylinder. Allow the user to enter in a radius and a height. Format the output to three decimal places. Use the constant PI and the method pow() from the Math class.
This is what I've done so far but it can not run. Can anyone help me ?
import Java.util Scanner;
public class Ex5 {
public static void main (String[] args)
{
Scanner input.new Scanner(System.in);
double radius,height,area;
System.out.print("Please enter the radius of the Cylinder");
radius = input.nextDouble();
System.out.print("Please enter the height of the Cylinder");
height = input.nextDouble();
area = (4*Math.PI*radius)+2*Math.PIMath.POW(radius,2);
System.out.println("The surface of the cylinder" + area);
}
}