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