Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Cone {
- private double radius;
- private double height;
- public Cone() {
- radius = 1;
- height = 1;
- }
- public Cone( double i, double j) {
- radius = i;
- height = j;
- }
- public double volume(){
- return (1.0/3) * Math.PI * radius * radius * height;
- }
- public double perimeter() {
- return (1/3) * (22/7.0) * radius * radius * height;
- }
- public double area() {
- return (22/7.0) * radius * (radius + Math.sqrt(height * height) + (radius * radius));
- }
- public String toString() {
- return "The volume and area of this Cone is " + "" + area();
- }
- public void setVariables(double l, double w) {
- height = w;
- radius = l;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement