So, according to Console output, if array size is 20(even), it fills with :
[10,10,10,10,10,10,10,10,10,10,13,13,13,13,13,13,13,13,13,13]
Then if array size is 21(odd), it fills as
[10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,13,13,13,13,13]
According to console output, my code met the requirement,
If array size is even, fill half of array with start value, half with end value;
if array size is odd, fill LARGER part of array with start value, and SMALLER with end value...
But my code can't pass the tests...
package en.codegym.task.pro.task05.task0516;
import java.util.Arrays;
/*
Filling an array
*/
public class Solution {
public static int[] array = new int[21];
public static int valueStart = 10;
public static int valueEnd = 13;
public static void main(String[] args) {
//write your code here
int startBorder;
if ((array.length % 2) == 0){
startBorder = array.length / 2;
}else{
startBorder = (int)(array.length * 0.8);
}
Arrays.fill(array, 0, startBorder, valueStart);
Arrays.fill(array, startBorder, array.length, valueEnd);
System.out.println(Arrays.toString(array));
}
}