-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.java
More file actions
37 lines (33 loc) · 761 Bytes
/
Calculator.java
File metadata and controls
37 lines (33 loc) · 761 Bytes
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
public class Calculator {
public void calc(DataSaver forCalc)
{
double num1 = forCalc.DataSaverGetD1();
double num2 = forCalc.DataSaverGetD2();
String type_of_operation = forCalc.DataSaverGetC();
double temp_num=0;
if (type_of_operation.equals("+"))
{
temp_num = num1+num2;
}
else if (type_of_operation.equals("-"))
{
temp_num = num1-num2;
}
else if (type_of_operation.equals("*"))
{
temp_num = num1*num2;
}
else if (type_of_operation.equals("/") | type_of_operation.equals(":"))
{
if (num2 ==0 | (num1 == 0 & num2 ==0))
temp_num = 0;
else
temp_num = num1/num2;
}
else if (type_of_operation.equals("^"))
{
temp_num = Math.pow(num1,num2);
}
forCalc.DataSaverSetD(temp_num);
}
}