Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

using JAVA Instructions: Using the Java naming conventions and javadoc comments

ID: 3585916 • Letter: U

Question

using JAVA

Instructions:

Using the Java naming conventions and javadoc comments create the

following.

You are a scientific computing company known as thefourthwall at

www.thefourthwall.net

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 th

e 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 quest

ion. 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 comme

nt.

Explanation / Answer

Please find my implementation.

public class Cone {

  

   private static final double PI = 3.14;

   private double height;

   private double radius;

   // setters and getters

   /**

   * @return height of the cone

   */

   public double getHeight() {

       return height;

   }

  

   /**

   * @return radius of the cone

   */

   public double getRadius() {

       return radius;

   }

  

   /**

   * @param height

   */

   public void setHeight(double height) {

       this.height = height;

   }

  

   /**

   * @param radius

   */

   public void setRadius(double radius) {

       this.radius = radius;

   }

  

   /**

   * @return surface area of the cone

   */

   public double area() {

       double length = Math.sqrt(radius * radius + height * height);

       return PI * radius * (radius + length);

   }

  

   /**

   * @return volume of the cone

   */

   public double volume() {  

       return (PI*radius*radius*height)/3.0;

   }

  

   public void print() {

       System.out.println("Cone height is "+height);

       System.out.println("Cone radius is "+radius);

       System.out.println("Cone surface area is "+area());

       System.out.println("Cone volume is "+volume());

   }

  

   public static void main(String[] args) {

      

       Cone cone = new Cone();

      

       cone.setHeight(4.5);

       cone.setRadius(3.5);

      

       cone.print();

   }

}

/*

Sample run:

Cone height is 4.5

Cone radius is 3.5

Cone surface area is 101.11763960919764

Cone volume is 57.69750000000001

*/