In: Computer Science
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a package named threeDimensional and put all 3 of the classes discussed below in this package
Include a header comment to EACH OF your files, as indicated in your instructions. Here's a link describing the header. Note that headers are not meant to be in Javadoc format.
Note that Javadoc is a huge part of your grade for this assignment. Javadoc requires that every class, every field, every constructor, and every method have a general (useful) comment and all relevant tags. This includes @param tags for methods and constructors and @param and @return tags for methods.
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================
// Cube.java
package threeDimensional;
public class Cube {
private int lengthOfSide;
public Cube() {
this.lengthOfSide = 1;
}
/**
* @param lengthOfSide
*/
public Cube(int lengthOfSide) {
this.lengthOfSide =
lengthOfSide;
}
/**
* @return the lengthOfSide
*/
public int getLengthOfSide() {
return lengthOfSide;
}
/**
* @param lengthOfSide
* the lengthOfSide to set
*/
public void setLengthOfSide(int lengthOfSide) {
this.lengthOfSide =
lengthOfSide;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Cube [" + lengthOfSide +
"]";
}
public int getSurfaceArea()
{
return 6*lengthOfSide;
}
public double getVolume()
{
return
Math.pow(lengthOfSide,3);
}
}
==========================================
// Sphere.java
package threeDimensional;
public class Sphere {
private double radius;
public Sphere() {
this.radius = 1.0;
}
/**
* @param radius
*/
public Sphere(double radius) {
this.radius = radius;
}
/**
* @return the radius
*/
public double getRadius() {
return radius;
}
/**
* @param radius
* the radius to set
*/
public void setRadius(double radius) {
this.radius = radius;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Sphere [" + radius +
"]";
}
public double getSurfaceArea() {
return 4 * Math.PI *
Math.pow(radius, 2);
}
public double getVolume() {
return (4.0 / 3.0) * Math.PI *
Math.pow(radius, 3);
}
}
===========================================
// Program4.java
package threeDimensional;
import java.util.Scanner;
public class Program4 {
public static void main(String[] args) {
/*
* Creating an Scanner class object
which is used to get the inputs
* entered by the user
*/
Scanner sc = new
Scanner(System.in);
Cube firstCube=new Cube();
System.out.println(firstCube);
System.out.print("Please enter the
length of the side for firstCube:");
int side=sc.nextInt();
firstCube.setLengthOfSide(side);
Cube secondCube = new
Cube(8);
Cube thirdCub = new Cube(3);
int accessorValue =
firstCube.getLengthOfSide();
System.out.println("First Cube:
");
System.out.println("First Cube side
length:"+accessorValue);
System.out.println("Second Cube:
");
System.out.println("Second Cube
surface area: "+secondCube.getSurfaceArea());
System.out.println("Third
Cube:");
System.out.println("Third Cube
volume:"+thirdCub.getVolume());
}
}
===========================================
Output:
=====================Could you plz rate me well.Thank You