I'm working on an assignment that requires the user to input an undecided number of integers, and then those numbers are to be used in other calculations. But for example if I have these 6 numbers. 1 2 3 4 5 6 and I want to extract only 2 4 and 6 from the input how would I do that? (make notices that this is just an example, the user can put in 20 different numbers, or only 4) I just want to be able to chose to pick every second element. To add more info, I need the first number in the array to be for one calculation, then the second for another calculation and then the first and the second. Basically I want to be able to assign every even array index numbers to a integer and every odd array index numbers to another integer. Like this :
"if (i % 2 == 0){int first = numbers [i]; System.out.println("This is the first" + first) } else if (i % 2 == 1) { int second = numbers [i] ; System.out.print("This is the second. " + second);}" But when I do so, it only appears in the first one..
0.