Computer Science, asked by romanthapa2004, 1 month ago

3. Create a class cylinder with attributes radius and height, each of which has a default value of 10. Provide a method that calculates the cylinder's volume, which is pi multiplied by the square of the radius and by the height. It has the set and get Methods for both radius and height. The set method should verify that radius and height are positive number. Write a program to test class cylinder.

Answers

Answered by anjumanyasmin
0

public double getRadius()

{

return radius;

}//ends accessor method getRadius

public double getHeight()

{

return height;

}//ends accessor method getHeight

Answered by yassersayeed
0

Answer: public class cylinder{  

   public static void main(String args[])  

   {  

   int height=10;  

   int radius=10;  

   double pie=3.14285714286;  

   double volume=pie*(radius*radius)*height;  

       System.out.println("Volume of the cylinder="+volume);  

    }  

}  

Similar questions