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

The code needs to be complete BOX The program should be able to create (instanti

ID: 3859828 • Letter: T

Question

The code needs to be complete
BOX
The program should be able to create (instantiate) three types of boxes. The first box would use the default constructor. The second box would be a cube and only need one parameter. The third box would be a rectangular solid and you will send in three parameters to the constructor
You should be able to perform the following calculations on your box: surface area of the entire box and volume. Furthermore, you should be able to make your box larger and smaller in the following two different ways:
• Specify by how much larger (multiplier) you would like to enlarge each dimension of the object. For example, makeLarger(2) would multiply the length, width, and height of the box by 2.
• Specify the specific amount you would like to add to each dimension of the box. For example, makeLarger(1, 3, 5) would add 1 to the length, 3 to the width, and 5 to the height of the box.
Be sure to include methods for the following tasks:
1. Constructors (three)
2. Calculate and return the volume
3. Calculate and return the surface area
4. Enlarge the box by multiplying each side by a number
5. Enlarge the box by adding a number to each side
6. Output the dimensions
Demonstrate that your program works properly. You will need to test all of the constructors and all of the methods in your class. Display all results to two decimal places.
Input and output should be done with Dialog and Message boxes. Your program should be well documented internally and externally.

Explanation / Answer

import java.io.*;
import java.util.Scanner;

public class Box1
{

double length;
double width;
double height;

//************************************************
// Makes a Default Box

public Box1()
{
length = 16;
width = 12;
height = 8;
}
//************************************************


//************************************************
// Makes a User Created Box

public Box1(double l, double w, double h)
{
length = l;
width = w;
height = h;
}
//************************************************


//************************************************
// Makes a Cube

public Box1(double c)
{
length = c;
width = c;
height = c;
}
//************************************************
public void printDimensions(){
System.out.println("Length: "+length);
System.out.println("Width: "+ width);
System.out.println("Height: "+ height);
}
public void makeLarger(double multiplier){
length = (length * multiplier);
width = (width * multiplier);
height = (height * multiplier);
}

public void makeLarger(double a, double b, double c){
length = (length + a);
width = (width + b);
height = (height + c);
}

public double findVolume(){
return (length * width * height);
}

public double findSurfaceArea(){
return ((length*width*2)+(height * width *2)+(length*height*2));
}

public static void main(String[] args) {
Box1 firstBox = new Box1();
System.out.println("No Arg Constructor Box: ");
firstBox.printDimensions();
Box1 secondBox = new Box1(12);
System.out.println("One Arg Constructor Box: ");
secondBox.printDimensions();
Box1 thirdBox = new Box1(2,3,4);
System.out.println("Three Arg Constructor Box: ");
thirdBox.printDimensions();
System.out.println("Volume of box 3: "+ thirdBox.findVolume());
System.out.println("Surface Area of box 3: "+ thirdBox.findSurfaceArea());
thirdBox.makeLarger(5,1,3);
System.out.println("Third box after enlarging sides individually: ");
thirdBox.printDimensions();
thirdBox.makeLarger(2);
System.out.println("Third box after enlarging multiplicity: ");
thirdBox.printDimensions();
}
}