Alice Community Convert numeric value to roman numeral?

 Convert numeric value to roman numeral?
 veghead05 Guest   Status: Posts: n/a Convert numeric value to roman numeral? - 05-04-2009, 01:15 PM How do I convert a number into a roman numeral? I have an assignment to ask the user to enter a number, then display that number as a roman numeral. Where are the roman numerals?
 HisWorld Guest   Status: Posts: n/a 05-04-2009, 10:59 PM haha, its not as straight forward as you seem to think. you know the conversion right? 3 = III, 5 = V, 10 = X. Well just off the top of my head you will need to read the user input and set whatever they input to a numeric veriable. then have a series of conditional statements "if-then, else" For each possible number you need to dispaly what you know is the equivalent roman numerial. ex. user inputs a five, you set that equal to a variable named "world.numbers" have maybe ten if statements that run, "if world.numbers == 1 output I else ................... if world.number == 5 output 5 I would suggest you have the user only be allowed to input number's between 1 and some number like 10. This can be down by using a while loop, "while both 0 < world.numbers <= 10" Tell me if this helps
 EricSkogen Guest   Status: Posts: n/a 05-05-2009, 01:01 AM As far as I know, there are no "Roman Numeral" objects. You would have to use the Latin characters. output them just like you would any other text. As far as the conversion goes, you could try the 1=I 2=II approach, but if you need to accept a large set (>20) perhaps this would be more time efficient.
 Scott300 Senior Member   Status: Offline Posts: 80 Join Date: Feb 2009 Location: Ohio 05-05-2009, 11:10 PM var number = 6 //test number var times into 100 = 0 //if its 0 that means it cannot go into it do same for 50,5 var remainder after 100 = 0 // the remaining amount after its been divided do same for 50,5 bool 100 perfect = false // this tells us later if there is no remainder on the 100 do the same for 50,5 string finishednumber == "" // its blank for now, this is where we will write our finished digits to if number can be divided by 100 in any way { times into 100 = number/100 remainder after 100 = remainder if remainder after 100 == 0 { 100 perfect == true } } //repeat for 50,5 if times into 100 > 0 { loop times=times into 100 { finishednumber = X.finishednumber } } and so on you need to make sure you put the remainders in there also I am getting tired of writing this its a pain in the ass tbh if you really need this finished send me a pm ill help you with it =)
 Hmm..
 veghead05 Guest   Status: Posts: n/a Hmm.. - 05-12-2009, 04:44 PM I'm actually really confused by ur post scott, could you explain what you are doing there? The comments helped a little but I'm still lost.
Scott300
Senior Member

Status: Offline
Posts: 80
Join Date: Feb 2009
Location: Ohio
05-12-2009, 07:18 PM

Quote:
 Originally Posted by veghead05 I'm actually really confused by ur post scott, could you explain what you are doing there? The comments helped a little but I'm still lost.
Tonight ill try and work it out in Alice instead of my head and post my findings.

Scott300
Senior Member

Status: Offline
Posts: 80
Join Date: Feb 2009
Location: Ohio
05-13-2009, 11:59 AM

OK, this works about 90% try like 122 for an example number. It has trouble converting any number that has 50 in it (ex- 151). But other than that it works great!
Attached Files
 roman.a2w (225.9 KB, 127 views)

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge