I was tasked with having an array that starts with size 10, then have user input heights in inches and stores it inside the array and then a new array converts all of those elements inside the initial array to cm. I have absolutely no idea what to do and really need help. How do I fix this?
double[] heightInches = new double[10];
int currentSize = 0;
Scanner in = new Scanner(System.in);
System.out.print("Please enter heights (inches), Q to quit: ");
while (in.hasNextDouble() && currentSize < heightInches.length)
{
heightInches[currentSize] = in.nextDouble();
currentSize++;
}
double[] result = convert(heightInches);
System.out.println("Heights in cm: " + result);
}
public static double[] convert(double[] inches) {
double heightCm[] = new double[inches.length];
for( int i = 0; i < inches.length; i++)
{
heightCm[i] = inches[i] * 2.54;
}
return heightCm;
}
}