Can you spot a problem with the next loop?
for(int i = 1; i <= totalNumbers; i++){ System.out.print("Number " + i + ": "); int inputNumbers = console.nextInt(); }
You run the totalNumbers once and every time you create a new int called inputNumbers and save the resulting value from the console. Also where do you change the minMax value? In addition, Math.min(or max) does not accept single parameters and does not even compile.
You now have several options:
- Either store all the numbers in an array, and then cross this for the min and max elements using some utility method.
- Set some minimum and maximum value and run the loop to get all the elements, as well as keep track of the min and max cycles.
I am not writing any solution, because I want you to try it yourself.
source share