123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
-
- import java.util.Scanner;
- /**
- * Created by leon on 2/9/18.
- */
- public class Console {
- Calculator calc = new Calculator();
-
- public static void print(String output, Object... args) {
- System.out.printf(output, args);
- }
-
- public static void println(String output, Object... args) {
- print(output + "\n", args);
- }
-
- public static String getMethod() {
- Scanner scanner = new Scanner(System.in);
- String userInput = scanner.nextLine();
- return userInput;
- }
-
- public static String switchStatment() {
- Scanner scanner = new Scanner(System.in);
- String ultimateAnswer = "";
- Boolean turnOff = false;
- switch (getMethod()) {
- case "add" :
- System.out.println("Enter your numbers:");
- double userInput = scanner.nextDouble();
- double nextInput = scanner.nextDouble();
-
- double answer = Calculator.add(userInput, nextInput);
- ultimateAnswer = Double.toString(answer);
- return ultimateAnswer;
-
- case "subtract" :
- System.out.println("Enter your numbers:");
- userInput = scanner.nextDouble();
- nextInput = scanner.nextDouble();
-
- answer = Calculator.subtract(userInput, nextInput);
- ultimateAnswer = Double.toString(answer);
- return ultimateAnswer;
-
- case "multiply" :
- System.out.println("Enter your numbers:");
- userInput = scanner.nextDouble();
- nextInput = scanner.nextDouble();
-
- answer = Calculator.multiply(userInput, nextInput);
- ultimateAnswer = Double.toString(answer);
- return ultimateAnswer;
-
- case "divide" :
- System.out.println("Enter your numbers:");
- userInput = scanner.nextDouble();
- nextInput = scanner.nextDouble();
-
- answer = Calculator.divide(userInput, nextInput);
- ultimateAnswer = Double.toString(answer);
- return ultimateAnswer;
-
- case "quit" :
- return "quit";
-
-
- }
- return ultimateAnswer;
- }
-
- /*public static String getStringInput(String prompt) {
- Scanner scanner = new Scanner(System.in);
- println(prompt);
- String userInput = scanner.nextLine();
- return userInput;
- }
-
- public static Integer getIntegerInput(String prompt) {
- Scanner scanner = new Scanner(System.in);
- println(prompt);
- int userInput = scanner.nextInt();
- return null;
- }
-
- public static Double getDoubleInput(String prompt) {
- Scanner scanner = new Scanner(System.in);
- println(prompt);
- double userInput = scanner.nextDouble();
- double nextInput = scanner.nextDouble();
- double answer = Calculator.add(userInput, nextInput);
- return answer;
- }*/
-
- }
|