tampurus

1 calculator

Mar 28th, 2022 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.26 KB | None | 0 0
  1. import java.util.*;  
  2. public class Main
  3. {
  4.     public static void main(String[] args) {
  5.         Scanner fn = new Scanner(System.in);
  6.         System.out.println("Enter any two number");
  7.         int a = fn.nextInt();
  8.         int a = fn.nextInt();
  9.         int b = fn.nextINT();
  10.         int a = fn.nextInt();
  11.         System.out.println("Enter 1=+, 2=- , 3=*, 4=/");
  12.         int op = fn.nextInt();
  13.         int res;
  14.         if(op==1){
  15.             res = a+b;
  16.         }
  17.         else if (op==2){
  18.             res = a-b;
  19.         }
  20.         else if (op == 3){
  21.             res = a*b;
  22.         }
  23.         else if (op==4){
  24.             res = a/b;
  25.         }
  26.         System.out.println("Result is "+res);
  27.     }
  28. import java.util.*;  
  29. public class Main
  30. {
  31.     public static void main(String[] args) {
  32.         Scanner fn = new Scanner(System.in);
  33.         System.out.println("Enter any two number");
  34.         int a = fn.nextInt();
  35.         int a = fn.nextInt();
  36.         int b = fn.nextINT();
  37.         int a = fn.nextInt();
  38.         System.out.println("Enter 1=+, 2=- , 3=*, 4=/");
  39.         int op = fn.nextInt();
  40.         int res;
  41.         if(op==1){
  42.             res = a+b;
  43.         }
  44.         else if (op==2){
  45.             res = a-b;
  46.         }
  47.         else if (op == 3){
  48.             res = a*b;
  49.         }
  50.         else if (op==4){
  51.             res = a/b;
  52.         }
  53.         System.out.println("Result is "+res);
  54.     }
  55.  
Add Comment
Please, Sign In to add comment