Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. public class Cone {
  2.     private double radius;
  3.     private double height;
  4.    
  5.    
  6.     public Cone() {
  7.         radius = 1;
  8.         height = 1;
  9.     }
  10.     public Cone( double i, double j) {
  11.         radius = i;
  12.         height = j;
  13.     }
  14.     public double volume(){
  15.         return (1.0/3) * Math.PI * radius * radius * height;
  16.     }
  17.    
  18.     public double perimeter() {
  19.         return (1/3) * (22/7.0) * radius * radius * height;
  20.     }
  21.     public double area() {
  22.         return (22/7.0) * radius * (radius + Math.sqrt(height * height) + (radius * radius));  
  23.     }
  24.     public String toString() {
  25.         return "The volume and area of this Cone  is " + "" + area();
  26.     }
  27.     public void setVariables(double l, double w) {
  28.    
  29.         height = w;
  30.         radius = l;
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement