mit() Methode ergänzt
parent
bbe478ff81
commit
10f0aef19a
|
@ -122,13 +122,13 @@ public class Spreadsheet {
|
||||||
else if (formula.startsWith("PRODUKT(")) // e.g. PRODUKT(A3:B9)
|
else if (formula.startsWith("PRODUKT(")) // e.g. PRODUKT(A3:B9)
|
||||||
result = "" + prod(formula.substring(8, colon), endSubstring);
|
result = "" + prod(formula.substring(8, colon), endSubstring);
|
||||||
else if (formula.startsWith("MITTELWERT(")) // e.g. MITTELWERT(A3:A5)
|
else if (formula.startsWith("MITTELWERT(")) // e.g. MITTELWERT(A3:A5)
|
||||||
result = "" + mit(formula.substring(12, colon), endSubstring);
|
result = "" + mit(formula.substring(11, colon), endSubstring);
|
||||||
else if (formula.startsWith("STABW(")) // e.g. STABW(C6:D8) -> Standardabweichung
|
else if (formula.startsWith("STABW(")) // e.g. STABW(C6:D8) -> Standardabweichung
|
||||||
result = "" + stabw(formula.substring(7, colon), endSubstring);
|
result = "" + stabw(formula.substring(6, colon), endSubstring);
|
||||||
else if (formula.startsWith("MIN(")) // e.g. MIN(C13:H13) -> kleinster Wert
|
else if (formula.startsWith("MIN(")) // e.g. MIN(C13:H13) -> kleinster Wert
|
||||||
result = "" + min(formula.substring(5, colon), endSubstring);
|
result = "" + min(formula.substring(4, colon), endSubstring);
|
||||||
else if (formula.startsWith("MAX(")) // e.g. MAX(A1:A10) -> größter Wert
|
else if (formula.startsWith("MAX(")) // e.g. MAX(A1:A10) -> größter Wert
|
||||||
result = "" + max(formula.substring(5, colon), endSubstring);
|
result = "" + max(formula.substring(4, colon), endSubstring);
|
||||||
else if (!formula.isEmpty()) {
|
else if (!formula.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
result = "" + calculate(formula);
|
result = "" + calculate(formula);
|
||||||
|
@ -199,9 +199,25 @@ public class Spreadsheet {
|
||||||
* @return The arithmetic average calculated.
|
* @return The arithmetic average calculated.
|
||||||
*/
|
*/
|
||||||
private long mit(String startCellName, String endCellName) {
|
private long mit(String startCellName, String endCellName) {
|
||||||
|
long result = 0;
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
for(char col = startCellName.charAt(0); col <= endCellName.charAt(0); col++){
|
||||||
|
|
||||||
return 0;
|
for(int row = Integer.parseInt(startCellName.substring(1)); row <= Integer.parseInt(endCellName.substring(1)); row++) {
|
||||||
|
String value = get((row - 1), (col - 'A'));
|
||||||
|
|
||||||
|
if(!value.isEmpty()){
|
||||||
|
result += Long.parseLong(value);
|
||||||
|
}else{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result /= counter;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue