Create a java package using the above information which holds the following clas
ID: 3590702 • Letter: C
Question
Create a java package using the above information which holds the following classes: 1. class "cone" includes a constant for PI called "our pi constant", and set and get methods for the height and radius of the cone. Also, calculate the cone's area and volume. 2. In class "cone user" there should be stages/steps in which we print data about the cone. The print method prints a string consisting of the attribute of the cone that is to be printed along with the numerical value of the attribute in question. The print method does NOT belong to an object. Step 1: print the cone's height. Step 2: print the cone's radius at the base Step 3: print the cone's surface area. Step 4: print the cone's volume. The print message should say the following: Cone (attribute) is (value).(Newline x2) print(String attribute, Float value) All classes and methods should be accompanied by a JavaDoc comment.Explanation / Answer
Cone.java
public class Cone
{
static final double ourPiConstant = 3.14;
double radius;
double height;
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double area()
{
double slant = Math.sqrt(Math.pow(radius, 2)+Math.pow(height, 2));
return ourPiConstant*radius*slant;
}
public double volume()
{
return (ourPiConstant*radius*radius*height)/3;
}
public Cone(double radius, double height) {
this.radius = radius;
this.height = height;
}
}
ConeUser.java
public class ConeUser {
public static void print(Cone c)
{
System.out.println("height is "+ c.getHeight());
System.out.println("radius is "+ c.getRadius());
System.out.println("area is "+ c.area());
System.out.println("volume is "+ c.volume());
}
}
tell me what exactly you want in the cone user class because once it talks about printing all the attributes stepwise and the next moment it talks about taking attribute name and value as arguments.
Comment and let me know what it is that you're looking for.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.