/* * a placeholder to write the average function * within a Hello World example... */ import java.util.Arrays; import java.util.Scanner; public class HelloWorld { /** * The main method - Java's starting point * @param args - the usual thing! */ public static void main(String[] args) { System.out.println("Hello world!"); // get an array of ints from the user int[] user_inputs = get_inputs(5); System.out.println("The array was " + Arrays.toString(user_inputs)); System.out.println("The average is " + average(user_inputs)); } /** * average! * @param A the int array to analyze * @return the element which, when added to * its index, is closest to 42 */ public static double average(int[] A) { double sum = 0.0; /* * you might want a for loop here! */ return sum; // not quite right :-) } /** * get_inputs returns an int array of * values prompted from the user * @param N - the number of values to get * @return - the array obtained */ public static int[] get_inputs(int N) { System.out.println("Enter " + N + " inputs:"); Scanner sc = new Scanner(System.in); int[] inputs = new int[N]; for (int i=0; i