diff --git a/calculator.java b/calculator.java new file mode 100644 index 00000000000..d67b10b4a32 --- /dev/null +++ b/calculator.java @@ -0,0 +1,34 @@ +import java.util.*; + +public class calculator{ + public static void main(String args[]){ + Scanner sc = new Scanner(System.in); + + System.out.println("Enter a : "); + int a = sc.nextInt(); + System.out.println("Enter b : "); + int b = sc.nextInt(); + System.out.println("Enter operator : "); + + char operator = sc.next().charAt(0); + + + switch(operator){ + + case '+' : System.out.println(a+b); + break; + case '-' : System.out.println(a-b); + break; + case '/' : System.out.println(a/b); + break; + case '*' : System.out.println(a*b); + break; + case '%' : System.out.println(a%b); + break; + default : System.out.println("wrong operator"); + + } + sc.close(); + + } +}