Cody

Solution 2649101

Submitted on 3 Jul 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
a = {'$12,001.87','$0.04','$103,887.55','$0.32'}; b = 115889.78; assert(abs(moneySum(a)-b) < 1e-4)

Error using str2num (line 35) Input must be a character vector or string scalar. Error in moneySum (line 3) b = sum(str2num(a)); Error in Test1 (line 3) assert(abs(moneySum(a)-b) < 1e-4)

2   Fail
a = {'$0.02'}; b = 0.02; assert(abs(moneySum(a)-b) < 1e-4)

Error using str2num (line 35) Input must be a character vector or string scalar. Error in moneySum (line 3) b = sum(str2num(a)); Error in Test2 (line 3) assert(abs(moneySum(a)-b) < 1e-4)

3   Fail
a = {'$81.47','$12.69','$91,337.60'}; b = 91431.76; assert(abs(moneySum(a)-b) < 1e-4)

Error using str2num (line 35) Input must be a character vector or string scalar. Error in moneySum (line 3) b = sum(str2num(a)); Error in Test3 (line 3) assert(abs(moneySum(a)-b) < 1e-4)

Suggested Problems

More from this Author95