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 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 Double getDoubleInput(String prompt) {
  19. Scanner scanner = new Scanner(System.in);
  20. println(prompt);
  21. String userInput = scanner.nextLine();
  22. return userInput.parseDouble();
  23. }
  24. public static Integer getIntegerInput(String prompt) {
  25. return null;
  26. }
  27. public static Double getDoubleInput(String prompt) {
  28. Scanner sc = new Scanner(System.in);
  29. Double userNumber1 = sc.nextDouble();
  30. return userNumber1;
  31. }
  32. }