You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
341 B

public class ParseString{
private String str;
public ParseString(String str){
this.str = str;
}
public double sumOfAll(){
String[] parts = this.str.split(",| +");
double total = 0;
for (int i = 0; i < parts.length; i ++){
total += Double.parseDouble(parts[i]);
}
return total;
}
}