Input and high cylinder bottom radius, the bottom area, and volume demand - Simple

 

import java.util.Scanner; 

class Cylinder

{

  double radius=0;

  double height;

  double PI=3.14;

  void area()

  {

    . The System OUT .println ( "bottom area of the cylinder is:" + (PI * radius * radius));

  }

  double volume()

  {

    return (PI*radius*radius)*height;

  }

}

public class App6_1 {

  public static void main(String[] args)

  {

    Cylinder volum = New cylinder ();

    Scanner reader=new Scanner(System.in);

    . The System OUT .print ( "Please enter the cylinder bottom circle radius:");

    volu.radius=reader.nextDouble();

    System.out.println();

    . System OUT .print ( "Please enter the cylinder high:");

    volu.height=reader.nextDouble();

    . The System OUT .println ( "bottom circle radius:" + volu.radius);

    volu.area ();

    . The System OUT .println ( "cylindrical volume:" + volu.volume ()); 

  }

}

 

operation result:

 

Guess you like

Origin www.cnblogs.com/duanqibo/p/11132752.html