Cody

Problem 495. Formatting currency numbers

Solution 3464313

Submitted on 29 Oct 2020 at 4:05
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
amt = 34.2; str = '$34.20'; assert(isequal(disp_currency(amt),str))

Error in solution: Line: 2 Column: 17 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

2   Fail
amt = 91337585; str = '$91,337,585.00'; assert(isequal(disp_currency(amt),str))

Error in solution: Line: 2 Column: 17 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

3   Fail
amt = -63234922.46; str = '($63,234,922.46)'; assert(isequal(disp_currency(amt),str))

Error in solution: Line: 2 Column: 17 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

4   Fail
amt = 2784.9; str = '$2,784.90'; assert(isequal(disp_currency(amt),str))

Error in solution: Line: 2 Column: 17 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

Suggested Problems

More from this Author50

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!