Roman Numeral Conversions 
Author Message
 Roman Numeral Conversions

JustForFun:
DO
   INPUT "Number to convert: ", UserNumber%

   Thousands% = UserNumber% / 1000
   UserNumber% = UserNumber% - (Thousands% * 1000)
   Hundreds% = UserNumber% / 100
   UserNumber% = UserNumber% - (Hundreds% * 100)
   Fifties% = UserNumber% / 50
   UserNumber% = UserNumber% - (Fifties% * 50)
   Tens% = UserNumber% / 10
   UserNumber% = UserNumber% - (Tens% * 10)
   Fives% = UserNumber% / 5
   UserNumber% = UserNumber% - (Fives% * 5)
   Ones% = UserNumber%

   RomanNumeral$ = STRING$("M", Thousands%)     ' powerbasic syntax

   SELECT CASE Hundreds%
      CASE 9 : RomanNumeral$ = RomanNumeral$ + "CM"
      CASE 8 : RomanNumeral$ = RomanNumeral$ + "CCM"
      CASE ELSE : RomanNumeral$ = RomanNumeral$ + STRING$("C",
Hundreds%)
   END SELECT

   RomanNumeral$ = RomanNumeral$ + STRING$("L", Fifties%)

   SELECT CASE Tens%
      CASE 4 : RomanNumerals$ = RomanNumeral$ + "XL"
      CASE ELSE : RomanNumeral$ = RomanNumeral$ + STRING$("X", Tens%)
   END SELECT

   RomanNumeral$ = RomanNumeral$ + STRING$("V", Fives%)

   SELECT CASE Ones%
      CASE 4 : RomanNumeral$ = RomanNumeral$ + "IV"
      CASE ELSE : RomanNumeral$ = RomanNumeral$ + STRING$("I", Ones%)
   END SELECT

   PRINT "The Roman Numeral for that number is: " RomanNumeral$

   PRINT
   PRINT "Convert another?"
   a$ = UCASE$(INPUT$(1))                         ' PowerBASIC syntax
   IF a$ = "Y" THEN Finished% = 0 ELSE Finished% = -1
LOOP UNTIL Finished%

END



Sun, 15 Oct 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. ROMAN NUMERAL CONVERSION!

2. Arabic number > Roman numeral and / or Roman numeral > Arabic number

3. Arabic number > Roman numeral and / or Roman numeral > Arabic number

4. Roman Numerals (VBA Code/MS Access)

5. Roman Numerals

6. Roman numerals...

7. Roman Numerals Revisited

8. Roman Numerals revisited

9. Roman Numerals chart to 1,000,000

10. Parsing Roman Numerals

11. Roman numerals in VB

12. Converting numbers to their Roman Numeral Equivalent

 

 
Powered by phpBB® Forum Software