Advertisement
jflan15

Untitled

Oct 17th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1.  
  2. public class Cone {
  3. //Name Variables   
  4. private double radius;
  5. private double height;
  6.  
  7. public Cone() {
  8.     radius = 1;
  9.     height = 1;
  10. }
  11. public Cone(double r, double h) {
  12.     radius = r;
  13.     height = h;
  14. }
  15. public double volume() {
  16.     return (1.0/3) * Math.PI *(radius * radius) * height;
  17. }
  18. public double area() {
  19.     return Math.PI * radius * (radius + Math.sqrt((height * height ) + (radius * radius)));
  20. }
  21. public String toString () {
  22.     return "The Volume and the Area of the cone is " + volume() + " " + area();
  23. }
  24. public void setVariables(double r, double h) {
  25. r = 1;
  26. h = 1;
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement