First you need something to read input from. I always use a
BefferedReader. You need to import the java.io package and then dot
he following to read a String:
BufferedReader in = new BufferdReader(new
InputStreamReader(System.in));
String s = in.readLine();
To get an int from a String:
int i = Integer.parseInt(s);
Hope this help. Sorry, but I didn't have time to redo your code. Just
integrate the above into your application.