While reading the Javadoc and the tutorials is excellent advice, I think
that's pretty hard on someone who is brand new. It's unfortunate that
Java doesn't provide a nice input object for you like System.out is a
nice output object, but that's how it is.
After checking the tutorials, see if you can find this:
BufferedReader in
= new BufferedReader(new InputStreamReader(System.in));
That's what you need to make a nice reader. Now you need to get the
String that the user types, and then turn that String into an integer.
Here's a hint:
KyoGaSuki wrote:
public class Digits {
public static void main(String[] args) {
// TODO, add your application code
int userNumber;
BufferedReader in
= new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a 4-digit integer: ");
String inputString = in.readline();
}
}
That makes the nice input reader for you, and calls the right method to
read the input. That's steps one and two above. Now you have to figure
out how to go from inputString to userNumber.
If you can find the two lines I added in the Javadocs and the tutorials
(see Lew's post), you should now have much better idea how to look for
that third step, converting a String to an integer.