Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Cone {
- //Name Variables
- private double radius;
- private double height;
- public Cone() {
- radius = 1;
- height = 1;
- }
- public Cone(double r, double h) {
- radius = r;
- height = h;
- }
- public double volume() {
- return (1.0/3) * Math.PI *(radius * radius) * height;
- }
- public double area() {
- return Math.PI * radius * (radius + Math.sqrt((height * height ) + (radius * radius)));
- }
- public String toString () {
- return "The Volume and the Area of the cone is " + volume() + " " + area();
- }
- public void setVariables(double r, double h) {
- r = 1;
- h = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement