title: Multiple values with only one scanner method?
body: <p>I have an assignment where I need to do certain calculations in separate methods using data entered by the user. My problem is with the user input. It is supposed to be done with a separate method (I do not think I am allowed to use arrays for storing the inputs). The user should be able to enter as many values they want and then exit with "q". The program should then take the first two numbers, calculate e.g. an area and volume with those (with other methods I did not include here), present the result, take the next two numbers the user entered, calculate and present results. This should be repeated until it reaches the "q" value. So for example:</p>
  
  <pre><code>    Enter your values: 9 5 3 7 q
      radius: 9 height: 5
      Area = 254
      Volume = 424
  
      radius: 3 height: 7
      Area = 28
      Volume = 65
  </code></pre>
  
  <p>A problem I am having is that only the first value is assigned to a variable and then the user has to enter data again for the next variable, even though there's still more numbers left from the first time.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Stack {
     private static Scanner input = new Scanner(System.in);
  
     public static void main(String[] args) {
  
        int radie, height;
  
        radie = userInput("");
        height = userInput("");
  
     }
  
     public static int userInput(String message) {
        int number = Integer.MAX_VALUE;
  
        while (number == Integer.MAX_VALUE) {
           System.out.print(message);
           if (input.hasNextInt()) {
              number = input.nextInt();
  
           }
           input.nextLine();
        }
        return number;
     }
  }
  </code></pre>
  
  <p>I understand there are massive flaws in my code here, I'm very lost and not sure where to even start with solving the problem. Any help or tips are very welcome! Thanks in advance!</p>