-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimplecalc.java
More file actions
59 lines (43 loc) · 1.09 KB
/
Simplecalc.java
File metadata and controls
59 lines (43 loc) · 1.09 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package JavaPrimer;
public class Simplecalc {
// static double val1 = 100.0;
// static double val2 = 50.0;
// char operator;
public static void main(String[] args) {
double val1 = 100.0;
double val2 = 50.0;
double result;
char operator = '/';
if (operator == '+') {
result = val1 + val2;
} else if (operator == '-') {
result = val1 - val2;
} else if (operator == '/') {
result = val1 / val2;
} else if (operator == '*') {
result = val1 * val2;
}
else {
result = 0.0;
}
System.out.println(result);
Simplecalc a = new Simplecalc();
a.factorial();
a.array();
}
int kval = 5;
int fac=1;
void factorial(){
while(kval > 1){
fac *= kval;
kval -= 1;
}
System.out.println(fac);
}
void array(){
float[] array = {0.01f, 0.02f, 0.03f};
for (float a :array) {
System.out.println(a);
}
}
}