1
0
Fork 0

sum of a cell block

main
ERANZER 2024-01-05 11:58:29 +01:00
parent f19c749e0b
commit 9c5b38d9db
2 changed files with 15 additions and 8 deletions

View File

@ -15,12 +15,12 @@ public class Axel {
String cell, in;
Scanner kb = new Scanner(System.in);
spr.put("A3", "3");
spr.put("A2", "1");
//spr.put("A3", "3");
//spr.put("A2", "1");
spr.put("B9", "=41+A2");
spr.put("J5", "=7*6");
spr.put("J6", "=3/2");
//spr.put("B9", "=41+A2");
//spr.put("J5", "=7*6");
//spr.put("J6", "=3/2");
while(true) {
System.out.println(spr);

View File

@ -150,9 +150,16 @@ public class Spreadsheet {
* @return The sum calculated.
*/
private long sum(String startCellName, String endCellName) {
// TODO implement
return 0;
int sum=0;
for(int i=startCellName.charAt(0)-'A'; i<=endCellName.charAt(0)-'A'; i++) {
for(int j=startCellName.charAt(1)-'1'; j<=endCellName.charAt(1)-'1'; j++) {
if(cells[i][j].isEmpty()) {
continue;
}
sum+=Integer.parseInt(cells[j][i].getValue());
}
}
return sum;
}
/**