about | help | code help+videos | done | prefs |
Given an input parameter 'num', return its Roman Numeral equivalent if 'num' is a positive integer value in the range 1<=num<=5000. If 'num' is outside that range, return "failed to convert". For this problem, you will use the common ancient interpretation of Roman Numerals such that the symbols used ONLY ADD to the total. The symbols should appear in strictly decreasing order of value. For example, the number 4 would be represented as "IIII" NOT as "IV". The number 1238 would be represented as "MCCXXXVIII". No other order is correct. Various symbols and their values are given below. You may assume that these are the only symbols to be used in the string (with the exception of the "fail to convert" message). I 1 V 5 X 10 L 50 C 100 D 500 M 1000 You might consider using helper methods (although I didn't). Look at the test data for examples. test2021_11_04_HL_un(1) → "I" test2021_11_04_HL_un(5000) → "MMMMM" test2021_11_04_HL_un(71824) → "failed to convert" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 280
Copyright Nick Parlante 2017 - privacy