-->
当前位置:首页 > 题库

PROGRAMMING:Cylinder design

Luz5年前 (2021-05-10)题库441
*< ol > defines a cylinder class cylinder
  • It contains the private attributes private int radius and height

  • Complete its setter getter method for the property

  • Complete the construction method cylinder (int radius, height) with parameters, which contains a sentence system. Out. Println ("constructor with para")
  • completes the non parametric construction method Cylinder (), calls the parametric construction method in the non parametric construction method, and the radius and the high assignment value are 2,1, which includes a System.out.println ("Constructor no para"); < / li>
  • Complete the volume method public int getvolumn() {} to calculate the volume of cylinder, π Using math.pi


  • *Define the test class main. In the main method, complete the following operations in order
  • Receive two numbers from the keyboard, the first is the radius, the second is the height, and use the two numbers just output to create the cylinder object C1, calculate the volume of C1 and output
  • Create the second cylinder object C2 by using the nonparametric construction method, calculate the volume of C2 and output
    ###Input format:
    Enter the radius and height on one line.
    ###Output format:
    Output the volume of each cylinder
    ###Input example:
    Here is a set of inputs. For example:
    ```in
    2 3
    ```
    ###Output example:
    The corresponding output is given here. For example:
    ```out
    Constructor with para
    thirty-seven
    Constructor with para
    Constructor no para
    twelve
    ```







    answer:If there is no answer, please comment