fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner scanner = new Scanner(System.in);
  13. ArrayList<Integer> numbers = new ArrayList<>();
  14. String input;
  15. do {
  16. int result = 0;
  17. String userNumbers = scanner.nextLine();
  18. String words[] = userNumbers.split(" ");
  19. for (String word : words) {
  20. result += Integer.parseInt(word) * Integer.parseInt(word);
  21. }
  22. numbers.add(result);
  23. System.out.println("Play again? Enter 'Y' or 'N'");
  24. input = scanner.nextLine();
  25. } while (!input.equalsIgnoreCase("N"));
  26. System.out.println(numbers);
  27. }
  28. }
Success #stdin #stdout 0.05s 4575232KB
stdin
5 5 5
Y
4 4 4
Y
5 5 5
N
stdout
Play again? Enter 'Y' or 'N'
Play again? Enter 'Y' or 'N'
Play again? Enter 'Y' or 'N'
[75, 48, 75]