Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Ex17_OperationsWithNumbers {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner sc = new Scanner(System.in);
  7.         int a = Integer.parseInt(sc.nextLine());
  8.         int b = Integer.parseInt(sc.nextLine());
  9.         String mathOperator = sc.nextLine();
  10.  
  11.         switch (mathOperator) {
  12.             case "+":{
  13.                 int calcul = a+b;
  14.                 System.out.println( a + " " + "+" + " " + b + " " + "=" + " " + calcul );
  15.                 break;}
  16.  
  17.             case "-":{
  18.                 int calcul = a-b;
  19.                 System.out.println( a + " " + "-" + " " + b + " " + "=" + " " + calcul );
  20.                 break;}
  21.  
  22.             case "/":{
  23.                 int calcul = a/b;
  24.                 System.out.println( a + " " + "/" + " " + b + " " + "=" + " " + calcul );
  25.                 break;}
  26.  
  27.             case "%":{
  28.                 int calcul = a%b;
  29.                 System.out.println( a + " " + "%" + " " + b + " " + "=" + " " + calcul );
  30.                 break;}
  31.  
  32.             case "*":{
  33.                 int calcul = a*b;
  34.                 System.out.println( a + " " + "*" + " " + b + " " + "=" + " " + calcul );
  35.                 break;}
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement