File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ public class Calculator
2+ {
3+ public void Calculator ()
4+ {
5+
6+ }
7+ public int add (int a , int b )
8+ {
9+ return (a +b );
10+ }
11+
12+ public int subtract (int a , int b )
13+ {
14+ return (a - b );
15+ }
16+
17+ public int multiply (int a , int b )
18+ {
19+ return (a * b );
20+ }
21+
22+ public int divide (int a , int b )
23+ {
24+ if (b == 0 )
25+ {
26+ System .out .println ("Error! Dividing by zero is not allowed" );
27+ return 0 ;
28+ }
29+ else
30+ {
31+ return (a / b );
32+ }
33+ }
34+
35+ public int modulo (int a , int b )
36+ {
37+ if (b == 0 )
38+ {
39+ System .out .println ("Error! Diving by zero is not allowed" );
40+ return 0 ;
41+ }
42+ else
43+ {
44+ return (a % b );
45+ }
46+ }
47+
48+ public static void main (String [] args )
49+ {
50+ Calculator myCalculator = new Calculator ();
51+ System .out .println (myCalculator .add (5 , 7 ));
52+ System .out .println (myCalculator .subtract (45 , 11 ));
53+
54+ }
55+ }
You can’t perform that action at this time.
0 commit comments