Console.java 1.1KB

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