Console.java 950B

123456789101112131415161718192021222324252627282930313233343536373839
  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. }