Have you written a change making program? It's the same concept for converting to roman numerals: spit out the largest possible denomination until there's nothing left in the remaining total. Start with that so you're no overwhelmed.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Do we get extra credit for helping you? :-)
Write down ALL of the rules to convert Roman to Decimal. Remember though L is 50 and X is 10, whether or not the 10 is added to or subtracted from the 5 depends upon what side of the L it is found. So, LX is 60 and XL is 40. Likewise for other numbers. V is 5, I is 1, VIII is 8, IV is 4, 3 is III, 2 is II, etc. So, what are ALL the rules? The reason why this is extra credit is that you need to use a read-ahead/backtrack algorithm to determine how to apply the math.
Ditto regarding rules to convert Decimal to Roman.
rubberman
Posting Virtuoso
1,564 posts since Mar 2010
Reputation Points: 277
Solved Threads: 179
Thanks for the quick responses.
I really appreciate it.
@Narue: I've never written a change making program. I didn't find any reference of that in my textbook. What should I look under?
@rubberman: No EC for you, but you've my gratitude? lol The most useless and undesirable prize I'd say. lol sorry.
No problem. I like to get folks to think about their problems, as a first step toward solving them. Understanding the scope is essential in that. As a teacher, sometimes I have to get in my students' faces. We all like to take the easy way out, but that doesn't help us elevate our skills.
rubberman
Posting Virtuoso
1,564 posts since Mar 2010
Reputation Points: 277
Solved Threads: 179
@Narue: I've never written a change making program. I didn't find any reference of that in my textbook. What should I look under?
It doesn't matter. If you've written a change program, you can use the concepts you learned. Since you haven't, you have to do this program without that background knowledge.
It's simply, if you enter743, what's the largest Roman numeral that fits into this number. M doesn't. D does. Store the D and subtract the value leaving 243.
Now what's the largest? C, giving you DC and leaving 143. Continue until you have 0.
Once you get that done, add the functionality that instead of a simple CCCC you save the normal value CD instead. This is hard part.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
I can see why.
He means that if you have VIIII, that's at the 5 level with more than 3 Is. You need to promote that group to the next level (5 -> 10) to IX.
IIII alone is the 1 level, promotes to V
VIIII is the 5 level, promotes to X
XIIII is back to the 1 level (X is not one step from I) so IIII promotes to V
Exact same pattern for XXXX and CCCC
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944