Console.java 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 void printResult(Double result) {
  13. System.out.println(result);
  14. }
  15. public static String getStringInput(String prompt) {
  16. Scanner scanner = new Scanner(System.in);
  17. println(prompt);
  18. String userInput = scanner.nextLine();
  19. return userInput;
  20. }
  21. public static Integer getIntegerInput(String prompt) {
  22. Scanner scanner = new Scanner(System.in);
  23. println(prompt);
  24. Integer userInput = scanner.nextInt();
  25. return userInput;
  26. }
  27. public static Double getDoubleInput(String prompt) {
  28. Scanner scanner = new Scanner(System.in);
  29. println(prompt);
  30. Double userInput = scanner.nextDouble();
  31. return userInput;
  32. }
  33. }