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

Java prog... public static void main(String[] args) { int aLength = 0; int aWidt

ID: 3628457 • Letter: J

Question


Java prog...
public static void main(String[] args)
{
int aLength = 0;
int aWidth = 0;
int aHeight = 0;
int aVolume = 0;



Scanner aNumberInput = new Scanner(System.in);

System.out.println("-------------------------------------------");
System.out.println("Calculates volume of box and"
+"amount of material, peanuts.");
System.out.println("-------------------------------------------");
System.out.println("");

System.out.println("VOLUME OF MATERIAL IS IN CUBIC INCHES.");
System.out.println("ALL OTHER MEASUREMENTS ARE IN INCHES.");
System.out.println("-------------------------------------------");
// Measurements of box
System.out.print("Please enter the length of the box:");
aLength = aNumberInput.nextInt();
System.out.print("Please enter the width of the box:");
aWidth = aNumberInput.nextInt();
System.out.print("Please enter the height of the box:");
aHeight = aNumberInput.nextInt();
System.out.println("");
//Volume of material
System.out.print("Please enter the volume of the materials:");
aVolume = aNumberInput.nextInt();
System.out.println("");
double bMaterial = (2 * aLength * aWidth + 2 * aHeight * aWidth
+ 2 * aHeight * aLength);
double bVolume = (aLength * aWidth * aHeight);
double bPeanuts = (bVolume - bMaterial);
if (bVolume < bMaterial) {
System.out.print("The gift is too large for the box.");
}
else {
System.out.println("The amount of material needed for the box is "
+ bMaterial + " square inches.");
System.out.println("The volume of the box is "
+ bVolume + " cubic inches.");
System.out.println("The box will need "
+ bPeanuts + " cubic inches of "peanuts".");
}
}
}

Explanation / Answer

if (aVolume > bVolume) { System.out.print("The gift is too large for the box."); } else { System.out.println("The amount of material needed for the box is " + bMaterial + " square inches."); System.out.println("... }

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