hey guys. after running my code nothing comes out in the console for some reason (i have no errors)
here is my code (it's a method example by my lecturer that i'm looking over)
import java.util.Random; import java.util.Scanner; public class Test { public static void main(String[] args) { int[] avals = createArray(); int[] bvals = createArray(); fillArrayRandomValues(avals); printArray(avals, "AVals"); fillArrayRandomValues(bvals); printArray(bvals, "BVals"); int atotal = calculateTotals(avals); int btotal = calculateTotals(bvals); printAnalysis(atotal, btotal); } private static void printAnalysis(int atotal, int btotal) { if(atotal > btotal) { System.out.println("A is greater than B"); } else if(btotal > atotal) { System.out.println("B is greater than A"); } else { System.out.println("A is equal to B"); } } private static int calculateTotals(int[] vals) { int total = 0; for(int i = 0; i < vals.length; i++) { total = total + vals[i]; } return total; } private static void printArray(int[] vals, String title) { System.out.print(title + ":\t"); for(int i = 0; i < vals.length; i++) { System.out.print(vals[i] + "\t"); } } private static void fillArrayRandomValues(int[] vals) { Random r = new Random(); for(int i = 0; i < vals.length; i++) { vals[i] = r.nextInt(1000); } } public static int[] createArray() { Scanner input = new Scanner(System.in); int size = input.nextInt(); int[] vals = new int[size]; return vals; } }
anyone know why it is not printing anything out in the console?
thanks in advance