For an assignment, my mission was to write a program that can calculate the capacity of a shipping container in 3 ways, using scanner. I need to compute the total number of boxes (of a user-given size) that will fit inside, how many boxes will fit in each dimension, and the total percentage-full the container will be. I'm relatively sure my math is correct, but the program won't compile and I'm just not seeing where the error is. Here's my source code:
import java.util.Scanner;
public class intermodal
{
public static void main(String [] args)
{
Scanner source = new Scanner (System.in);
//Calculate capacity of shipping container
int contLength = 5900;
int contWidth = 2350;
int contHeight = 2393;
int contVolume = (contLength*contWidth*contHeight);
//User enters box dimensions
int boxLength;
int boxWidth;
int boxHeight;
int boxVolume = (boxWidth*boxLength*boxHeight);
//Max number of boxes that will fit inside the container
int maxBoxes = contVolume/boxVolume;
//Calculate how many boxes fit in each dimension
int fitLength = 5900/boxLength;
int fitWidth = 2350/boxWidth;
int fitHeight = 2393/boxHeight;
//Calculate percentage-full container will be
int capacity = (boxVolume*maxBoxes)/contVolume*100;
System.out.println("What is the length of your shipping box (in mm)?");
boxLength = keyboard.nextInt();
System.out.println("What is the width of your shipping box (in mm)?");
boxWidth = keyboard.nextInt();
System.out.println("What is the height of your shipping box (in mm)?");
boxHeight = keyboard.nextInt();
System.out.println("If your box is" +boxLength "long x" +boxWidth "wide x" +boxHeight "high, you can fit:");
System.out.println(+fitLength "box(es) lengthwise" n\+fitWidth "box(es) across the width" n\+fitHeight "box(es) high");
System.out.println("for a total of" +maxBoxes "box(es) in a standard freight container.");
System.out.println("The container will be" +capacity "full.");
}
}
I can't find my boo-boo and I've been staring at it for hours. Suggestions are more than welcome before I go crazy.