Java Assignment ( Help )
So far I have this :
import java.util.*;
public class BallPacker {
public static void main(String[] args) {
Scanner myscanner = new Scanner (System.in);
int h, w, l;
float r;
double x, d, k, p;
int boxVolume;
double sphereVol;
int counter = 0;
double dec;
System.out.print("length (l): ");
l = myscanner.nextInt();
System.out.print("width (w): ");
w = myscanner.nextInt();
System.out.print("height (h): ");
h = myscanner.nextInt();
System.out.print("Ball Radius (r): ");
r = myscanner.nextFloat();
boxVolume = l*w*h;
//System.out.println("VOLUME: " + boxVolume);
k = 1.33;
p = 3.14;
d = Math.pow(r,3);
sphereVol = k*p*d;
x = Math.ceil(sphereVol);
System.out.println("Processing ...");
System.out.println("Might take few minutes depending on the entered dimensions.");
//while (((boxVolume - x) != 0) || ((boxVolume - x) < 0)){
if(boxVolume>(boxVolume-x)){
counter++;
}
/*if((boxVolume - x)>0){
counter++;
}*/
else{
System.out.println("COUNTING PROCESS COMPLETE!");
// break;
}
// }
System.out.println(counter + " balls can be placed inside that box you specified");
}
}
But it doessn't really work...
Can some 1 help me? edit the code?
Thanks

