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

The Java program should create three types of boxes, with 0, 1, or 3 parameters.

ID: 3633840 • Letter: T

Question

The Java program should create three types of boxes, with 0, 1, or 3 parameters. If a cube, user only provides the length of one side. User should specify the length, width, and height of the box. User also should have the ability to create a box with zero dimensions, using default values.
Allow the user to enlarge the box by 2 separate ways listed below:
• 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 (two ways)
5. Output the dimensions

Here are my methods for creating the box types. I have a lot of difficulty with creating Dialog and message boxes for input and output. I need assistance as to where I should go from this point. The program seems easy, but I am stuck...

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


public class Box1
{

double length;
double width;
double height;

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

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


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

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


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

Box1(double c)
{
length = c;
width = c;
height = c;
}
//************************************************

}
}

Explanation / Answer

Hope this helps, please rate! 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(); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote