Use Math class to calculate

Posted by LC on Stack Overflow See other posts from Stack Overflow or by LC
Published on 2010-03-20T01:01:28Z Indexed on 2010/03/20 1:11 UTC
Read the original article Hit count: 460

Filed under:
|
|
|

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);  
    }
}

© Stack Overflow or respective owner

Related posts about exercise

Related posts about match