Im hoping you can tell what its supposed to do from what I have so far. import j
ID: 3628263 • Letter: I
Question
Im hoping you can tell what its supposed to do from what I have so far.
import java.util.Scanner;
/**
* Calculates blah blah blah
*
* @author Idk
* @version 8-29-2010
*/
public class GiftBoxes
{
/**
* This declares the variables used for the program.
*@param args User-defined command line arguments (not used).
*/
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("... }