-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp13.java
35 lines (33 loc) · 798 Bytes
/
p13.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.*;
class p13
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int ans=0;
String s1 = sc.nextLine();
s1=s1.replaceAll(" ","");
s1=s1.replaceAll("[+]"," + ");
s1=s1.replaceAll("[-]"," - ");
s1=s1.replaceAll("[*]"," * ");
s1=s1.replaceAll("[/]"," / ");
String str[] = s1.split(" ");
int a = Integer.parseInt(str[0]);
int b = Integer.parseInt(str[2]);
switch(str[1].charAt(0))
{
case '+': ans = a+b;
System.out.println("Sum = "+ans);
break;
case '-': ans = a-b;
System.out.println("Substraction = "+ans);
break;
case '*': ans = a*b;
System.out.println("Multiplication = "+ans);
break;
case '/': ans = a/b;
System.out.println("Division = "+ans);
break;
}
}
}