Skip to content

Commit

Permalink
Merge pull request #6980 from gulatikeshav/patch-7
Browse files Browse the repository at this point in the history
Create calculator.java
  • Loading branch information
ossamamehmood authored Oct 31, 2023
2 parents bbc7634 + 8929199 commit 1ca3eb9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions calculator.java
Original file line number Diff line number Diff line change
@@ -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();

}
}

0 comments on commit 1ca3eb9

Please sign in to comment.