Code won't compile, but can't find the error....
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:
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 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.
Re: Code won't compile, but can't find the error....
Okay, first note that it is usually quite hard to find someone's errors without first posting your omelette ompile time errors, and sometimes people will not even look at your ode unless you have posted the errors or atleast tried to. Two, you should highlight your code with [code=Java][/code] tags. third you have to calculate information based on user input after you have gotten the user input. note that you can't use a variable you have not initialized (given a value to) yet.
Alsoyou might want to look into basic String conc, and the other information provided at the link below.
Lesson: Language Basics (The Java™ Tutorials > Learning the Java Language)