File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments