Guest User

Untitled

a guest
Jun 18th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. /* Write a Cylinder class whose objects can be characterised by two double values: one to denote the radius and the other to denote the height of a cylinder. a) Provide a constructor without parameters which would initialise the class fields to some default values, and another constructor which would take two parameters and initialise the fields to the values specified by the user. */
  2.  
  3. public class Cylinder {
  4.  
  5.   private double radius;
  6.   private double height;
  7.  
  8.   public Cylinder () {radius = 0.0; height = 0.0;}
  9.   public Cylinder (double a, double b) {radius = a; height = b;}
  10.  
  11.   public void changeRadius (double i) {
  12.     radius = i;
  13.   }
  14.  
  15.   public void changeHeight (double i) {
  16.     height = i;
  17.   }
  18.  
  19. }
Add Comment
Please, Sign In to add comment