Console.java 947B

12345678910111213141516171819202122232425262728293031323334353637
  1. import java.util.Scanner;
  2. /**
  3. * Created by leon on 2/9/18.
  4. */
  5. public class Console {
  6. public static void print(String output, Object... args) {
  7. System.out.printf(output, args);
  8. }
  9. public static void println(String output, Object... args) {
  10. print(output + "\n", args);
  11. }
  12. public static String getStringInput(String prompt) {
  13. Scanner scanner = new Scanner(System.in);
  14. println(prompt);
  15. String userInput = scanner.nextLine();
  16. return userInput;
  17. }
  18. public static Integer getIntegerInput(String prompt) {
  19. Scanner scanner = new Scanner(System.in);
  20. println(prompt);
  21. Integer userInput = scanner.nextInt();
  22. return userInput;
  23. }
  24. public static Double getDoubleInput(String prompt) {
  25. Scanner scanner = new Scanner(System.in);
  26. println(prompt);
  27. double userInput = scanner.nextDouble();
  28. return userInput;
  29. }
  30. }