forked from harshitbansal373/hacktoberfest2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculator.java
42 lines (42 loc) · 900 Bytes
/
Calculator.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
35
36
37
38
39
40
41
42
class Func
{
int num1,num2;
void getData(int a,int b)
{
num1=a;
num2=b;
}
int add()
{ return (num1+num2);}
int sub()
{ return (num1-num2);}
int mul()
{ return (num1*num2);}
int div()
{ return (num1/num2);}
int pon=1;
int pow()
{
for(int i=0;i<num2;i++)
{
pon=pon*num1;
}
return (pon);
}
}
class Calculator
{
public static void main(String args[])
{
Func f1=new Func();
int x=Integer.parseInt(args[1]);
int y=Integer.parseInt(args[2]);
int z=Integer.parseInt(args[0]);
f1.getData(x,y);
if(z==1){System.out.println(f1.add());}
else if(z==2){System.out.println(f1.sub());}
else if(z==3){System.out.println(f1.mul());}
else if(z==4){System.out.println(f1.div());}
else if(z==5){System.out.println(f1.pow());}
}
}