Numbers into array!
So mainly my program is supposed to keep taking user input until the user inputs 0. The integer's the user inputs will be placed into an array (the first value being the first number, the second value being the second number etc..) until all the integers that the user inputs are placed in the array.
This is what I have so far:
import java.io.*;
import java.util.*;
publicclass TrivialApplication{
publicstaticvoid main(String args[])throws IOException{
int scores = 1;
int score_i;
int [] score_array =newint[200];
BufferedReader kinput =
new BufferedReader (new InputStreamReader (System.in));
System.out.println("Enter numbers:");
while (scores != 0){
try{
scores = Integer.parseInt(kinput.readLine());
for (score_i = 0; score_i < score_array.length; score_i++){
score_array[score_i] = scores;
}
}catch (NumberFormatException nfe){
System.out.print("\nNumbers only Please: ");
scores = Integer.parseInt(kinput.readLine());
}
}
while (scores == 0){
break;
}
}
}
It takes the user's input until the user inputs 0. The only problem is that all values of the array are equal to the last number inputed (which has to be 0 since that is what you use to stop it). I know that somehow I am rewriting the value of the user's input each time they input a new value but how can i prevent this?
Message was edited by:
RAWR-itsanONION

