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

7 years ago
7 years ago
  1. public class ParseString{
  2. private String str;
  3. public ParseString(String str){
  4. this.str = str;
  5. }
  6. public double sumOfAll(){
  7. String[] parts = this.str.split(",| +");
  8. double total = 0;
  9. for (int i = 0; i < parts.length; i ++){
  10. total += Double.parseDouble(parts[i]);
  11. }
  12. return total;
  13. }
  14. }