Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Ex17_OperationsWithNumbers {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int a = Integer.parseInt(sc.nextLine());
- int b = Integer.parseInt(sc.nextLine());
- String mathOperator = sc.nextLine();
- switch (mathOperator) {
- case "+":{
- int calcul = a+b;
- System.out.println( a + " " + "+" + " " + b + " " + "=" + " " + calcul );
- break;}
- case "-":{
- int calcul = a-b;
- System.out.println( a + " " + "-" + " " + b + " " + "=" + " " + calcul );
- break;}
- case "/":{
- int calcul = a/b;
- System.out.println( a + " " + "/" + " " + b + " " + "=" + " " + calcul );
- break;}
- case "%":{
- int calcul = a%b;
- System.out.println( a + " " + "%" + " " + b + " " + "=" + " " + calcul );
- break;}
- case "*":{
- int calcul = a*b;
- System.out.println( a + " " + "*" + " " + b + " " + "=" + " " + calcul );
- break;}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement