ScratchData LogoScratchData
Back to jkibbe's profile

T$C - Integer to Roman Numeral Converter template

JKjkibbe•Created October 9, 2015
T$C - Integer to Roman Numeral Converter template
0
0
30 views
View on Scratch

Instructions

Enter an integer from 1 to 3000 and I will tell you the Roman Numeral equivalent. Test cases: 1 = I 8 = VIII 9 = IX 44 = XLIV 57 = LVII 199 = CXCIX 2001 = MMI 2417 = MMCDXVII 3000 = MMM

Description

Pseudocode: 1. Try to subtract the first value of 'dec' from your number. If it is possible (how can you test for this first?), do the subtraction then add the Roman Numeral with the same index ('i') value to the solution (using 'set solution' and 'join' blocks). Repeat. 2. Otherwise, if it is not possible, increment the value of i by one. And try again. 3. Repeat this process of testing, subtracting, and incrementing until the value of the number ('num') equals zero. Note: You do not need to change / edit the two lists in any way! Also, I included some blocks in the template that may be helpful [hint, hint]! Finally, it was necessary to include number like 900 and 40 in the lists to avoid solutions like 40 = XXXX and 90 = LXXXX, instead of XL and XC. More info on Roman Numerals here: https://en.wikipedia.org/wiki/Roman_numerals

Project Details

Project ID81361714
CreatedOctober 9, 2015
Last ModifiedJanuary 22, 2016
SharedOctober 9, 2015
Visibilityvisible
CommentsAllowed