Quick question
I need to produce this as an output for part of a program:
Enter number pair 1: 12 16
the user enter the 2 pairs of numbers at the end, my question is: How do I set the program to let me enter 2 pairs on one command, like
System.out.println("Enter a number: ");
n = input.nextInt();
The user would enter 12 16 in one statement.
What is the code for this?
[423 byte] By [
eleca] at [2007-10-2 10:59:39]

You could use [url http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html#nextLine()]Scanner.nextLine()[/url] to get the input string.
With that string, you could use [url http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#split(java.lang.String)]String.split()[/url] to get your array of separate tokens.
Then to convert each token string into an integer, you could use [url http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html#parseInt(java.lang.String)]Integer.parseInt()[/url].
Regards