Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- public class Calc {
- static Scanner scanner = new Scanner(System.in);
- public static void main(String[] args) {
- int a = getInt();
- int b = getInt();
- char operation = getOperation();
- int result = calc(a, b ,operation);
- System.out.println(result);
- }
- public static int getInt(){
- int num;
- if(scanner.NextInt()){
- num = scanner.nextInt();
- }
- return num;
- }
- public static char getOperation(){
- char operation = 0;
- if(scanner.hasNext()){
- operation = scanner.next().charAt(0);
- }
- return operation;
- }
- public static int calc(int a, int b, char operation){
- int result;
- switch (operation){
- case '+':
- result = a + b;
- break;
- case '-':
- result = a - b ;
- break;
- case '*':
- result = a * b ;
- break;
- case '/':
- result = a/b;
- break;
- }
- return result;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement