public static void main(String[] args) {
long c = getVolume(30,15,10) * 1000;
System.out.println("Litres in Pool: " + c);
}
public static long getVolume(int a, int b, int c) {
// litres of water to fill the pool
// length in metres // 1 meter cubic = 1000 liters
int length = 30;
int width = 20;
int depth = 10;
int cube = (length * width * depth) * 1000;
return cube;
}
}
Level 3 Concatenation ---- Not quite right --- not sure why .... Where is this wrong
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
luke
19 May 2019, 21:38
I think you are multiplying by 1000 twice; once in the method and again in the call?
Also, in the getVolume method, you don't need to declare the length, width, and depth with values. The values are passed in the arguments (int a, int b, int c).
public static long getVolume(int a, int b, int c) {
int cube = (a * b * c) * 1000; }
return cube;
then when you pass in your main method, you don't need to multiply by 1000 again, it's already converted to mL in the getVolume method.
Hope this helps and/or is correct for you
0