Skip to content

Commit 9382652

Browse files
authored
Merge pull request codec-akash#34 from Ayomal98/master
Added the SimpleCalculator.java file
2 parents f0a6ae1 + cc294ce commit 9382652

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Simple_Calculator.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.util.Scanner;
2+
3+
public class Simple_Calculator {
4+
public static void main(String[] args) {
5+
Scanner sc=new Scanner(System.in);
6+
System.out.println("Enter number 1 : ");
7+
Double num1=sc.nextDouble();
8+
System.out.println("Enter number 2: ");
9+
Double num2=sc.nextDouble();
10+
System.out.println("Enter the Operation");
11+
String op=sc.next();
12+
switch (op){
13+
case "+":
14+
System.out.println("Addition of "+num1+" & "+num2+"is : "+(num1+num2));
15+
break;
16+
case "-":
17+
System.out.println("Substraction of "+num1+" & "+num2+"is : "+(num1-num2));
18+
break;
19+
case "*":
20+
System.out.println("Multiplication of "+num1+" & "+num2+"is : "+(num1*num2));
21+
break;
22+
case "/":
23+
System.out.println("Division of "+num1+" & "+num2+"is : "+(num1/num2));
24+
break;
25+
default:
26+
throw new IllegalStateException("Unexpected value: " + op);
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)