Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- int selection = 0;
- int solution = 0;
- int x = 0;
- int y = 0;
- Calculator calculator = new Calculator();
- calculator.print_menu();
- Scanner input = new Scanner(System.in);
- selection = input.nextInt();
- input.nextLine(); // consumption of newline
- System.out.println("Input two numbers: ");
- x = input.nextInt();
- y = input.nextInt();
- input.close();
- switch (selection) {
- case 0:
- System.out.println("Bye!");
- break;
- case 1:
- solution = calculator.add(x, y);
- break;
- case 2:
- solution = calculator.sub(x, y);
- break;
- case 3:
- solution = calculator.mul(x, y);
- break;
- case 4:
- solution = calculator.div(x, y);
- break;
- // case 5:
- // calculator.factorial(5);
- // break;
- default:
- System.out.println("How did you get here?");
- }
- System.out.println("soln: " + solution);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement