You have been asked to work out the area of number of rectangles.
The input to your function is a array of longs. If the arrays length is odd you should return void. Otherwise you should use adjacent pairs of longs to calculate the area.
For example if the input is {4,4,5,5,6,6,7,7} you should return {16, 25, 36, 49}.
public class Area {
public static long[] workOutArea(long[] values){
}
}
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.runners.JUnit4;
public class SolutionTest {
@Test
public void testSomething() {
long[] val1 = {4l,4l,5l,5l,6l,6l,7l,7l};
Assert.assertArrayEquals(area.workOutArea(val1), new long[] {16l, 25l, 36l, 49l});
long[] val2 = {4l,4l,5l,5l,6l,6l,7l};
assertEquals(null, area.workOutArea(val2));
}
}