質問編集履歴
1
SumとAveのプログラムが不足していましたので追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,6 +40,70 @@
|
|
40
40
|
|
41
41
|
```
|
42
42
|
|
43
|
+
```Java
|
44
|
+
|
45
|
+
public class Sum{
|
46
|
+
|
47
|
+
public int Sum(int x,int y){
|
48
|
+
|
49
|
+
int first ,last;
|
50
|
+
|
51
|
+
int result = 0;
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
if(x <= y){
|
56
|
+
|
57
|
+
first = x;
|
58
|
+
|
59
|
+
last = y;
|
60
|
+
|
61
|
+
}else{
|
62
|
+
|
63
|
+
first = y;
|
64
|
+
|
65
|
+
last = x;
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
Add add = new Add();
|
70
|
+
|
71
|
+
// xからy,またはyからxまでの全ての和を求める
|
72
|
+
|
73
|
+
for(int i = first; i <= last; i=add.add(i,1)){
|
74
|
+
|
75
|
+
result = add.add(result,i);
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
return result;
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
```
|
86
|
+
|
87
|
+
```Java
|
88
|
+
|
89
|
+
public class Ave{
|
90
|
+
|
91
|
+
public float ave(int x,int y){
|
92
|
+
|
93
|
+
Add add = new Add();
|
94
|
+
|
95
|
+
Div div = new Div();
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
return (div.div(add.add(x ,y),2));
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
```
|
106
|
+
|
43
107
|
```javac
|
44
108
|
|
45
109
|
Calc.java:10: エラー: シンボルを見つけられません
|