My code is intended to take in an array of ints and return an array of ints with a length of twice the original array's length, minus 2.
The returned array should have values 1/3 and 2/3 between any given two values in the original array.
For example input array:
{400, 500, 600}
will return:
{400,433,466,500,533,566,600}
The code I have is as follows:
public static void main(String[] args){
System.out.println("Problem 9 tests");
int[] arr7={300, 400, 500};
System.out.println(highDef(arr7));
System.out.println(" ");
public static int[] highDef(int[] original) {
int[] newarr = new int[original.length*3-2];
newarr[0]=original[0];
int count=0;
while (count!=newarr.length) {
int increment=(original[count+1]-original[count])/3;
newarr[count+1]=original[count]+increment;
newarr[count+2]=original[count]+(count*increment);
count+=1;
}
return newarr;
count == newarr.length - 2... but then you're accessingnewarr[count+2]in the body of the loop. (I'd strongly advise you to useforloops for this sort of thing, by the way...)