Cody

# Problem 495. Formatting currency numbers

Solution 592610

Submitted on 6 Mar 2015 by goc3
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   Pass
%% amt = 34.2; str = '\$34.20'; assert(isequal(disp_currency(amt),str))

str = 0243 str = 02.43\$ n = 2 v = Empty matrix: 1-by-0 str = \$34.20

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

str = 0058573319 str = 00.58573319\$ n = 8 v = 6 9 str = 00.585733,19\$ str = 00.585,733,19\$ str = \$91,337,585.00

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

str = 6422943236 str = 64.22943236\$ n = 8 v = 6 9 str = 64.229432,36\$ str = 64.229,432,36\$ str = \$63,234,922.46 str = (\$63,234,922.46)

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

str = 094872 str = 09.4872\$ n = 4 v = 6 str = 09.487,2\$ str = \$2,784.90

### Community Treasure Hunt

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

Start Hunting!