Cody

# Problem 2413. Temperature Conversion Utility

Solution 2672693

Submitted on 9 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   Pass
T = 100; u1 = 'C'; u2 = 'F'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-212) < eps)

pair = 'CF' ans = 212 T_out = 212

2   Pass
T = 100; u1 = 'C'; u2 = 'R'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-671.67) < eps)

pair = 'CR' ans = 671.6700 T_out = 671.6700

3   Pass
T = 100; u1 = 'C'; u2 = 'C'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-100) < eps)

pair = 'CC' ans = 100 T_out = 100

4   Pass
T = 100; u1 = 'C'; u2 = 'K'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-373.15) < eps)

pair = 'CK' ans = 373.1500 T_out = 373.1500

5   Pass
T = 100; u1 = 'K'; u2 = 'F'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-(-279.67)) < eps)

pair = 'KF' ans = -279.6700 T_out = -279.6700

6   Pass
T = 100; u1 = 'K'; u2 = 'R'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-180) < eps)

pair = 'KR' ans = 180 T_out = 180

7   Pass
T = 100; u1 = 'K'; u2 = 'C'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-(-173.15)) < eps)

pair = 'KC' ans = -173.1500 T_out = -173.1500

8   Pass
T = 100; u1 = 'K'; u2 = 'K'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-100) < eps)

pair = 'KK' ans = 100 T_out = 100

9   Pass
T = 100; u1 = 'F'; u2 = 'F'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-100) < eps)

pair = 'FF' ans = 100 T_out = 100

10   Pass
T = 100; u1 = 'F'; u2 = 'R'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-559.67) < eps)

pair = 'FR' ans = 559.6700 T_out = 559.6700

11   Fail
T = 100; u1 = 'F'; u2 = 'C'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-37.7777778) < eps)

pair = 'FC' ans = 122.4000 T_out = 122.4000

Assertion failed.

12   Pass
T = 100; u1 = 'F'; u2 = 'K'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-310.9277778) < eps)

pair = 'FK' ans = 310.9278 T_out = 310.9278

13   Pass
T = 100; u1 = 'R'; u2 = 'F'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-(-359.67)) < eps)

pair = 'RF' ans = -359.6700 T_out = -359.6700

14   Pass
T = 100; u1 = 'R'; u2 = 'R'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-100) < eps)

pair = 'RR' ans = 100 T_out = 100

15   Pass
T = 100; u1 = 'R'; u2 = 'C'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-(-217.5944444)) < eps)

pair = 'RC' ans = -217.5944 T_out = -217.5944

16   Pass
T = 100; u1 = 'R'; u2 = 'K'; eps = 1e-4; assert(abs(T_convertor(T,u1,u2)-55.5555556) < eps)

pair = 'RK' ans = 55.5556 T_out = 55.5556

### Community Treasure Hunt

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

Start Hunting!