File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+
3+ public class calculator
4+ {
5+ public static void main (String [] args )
6+ {
7+ float a , b , res ;
8+ int choice ;
9+ Scanner scan = new Scanner (System .in );
10+
11+ System .out .println ("1. Addition" );
12+ System .out .println ("2. Subtraction" );
13+ System .out .println ("3. Multiplication" );
14+ System .out .println ("4. Division" );
15+ System .out .print ("Enter Your Choice (1-4): " );
16+ choice = scan .nextInt ();
17+
18+ if (choice >=1 && choice <=4 )
19+ {
20+ System .out .print ("\n Enter any Two Number: " );
21+ a = scan .nextFloat ();
22+ b = scan .nextFloat ();
23+
24+ if (choice ==1 )
25+ res = a +b ;
26+ else if (choice ==2 )
27+ res = a -b ;
28+ else if (choice ==3 )
29+ res = a *b ;
30+ else
31+ res = a /b ;
32+
33+ System .out .println ("\n Result = " +res );
34+ }
35+ else
36+ System .out .println ("\n Invalid Choice!" );
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments