Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Numbers to Roman Numerals Converter
#1
I been wanting to make this since the 1990's when I made back then in QBasic just a little chart on how to convert them in your head. 
I scoured my brain the last 2 days with this and finally gave in and used Chat GPT to help me figure it out. Since it used a FUNCTION, I removed it because
I don't really know how to use FUNCTION's yet. I've used them, but don't really have the experience. I placed all the code within the program instead and fixed a
couple things. Chat GPT had wrong DIM numbers so I changed that also. Going over this in my head, line-by-line I finally figured out how it works. It's a lot easier
for me to learn by trial and error though, so I doubt I will use Chat GPT much. To me, it's kind of like copying from someone else's test at school. But at least I'm 
trying to learn off of it. 

What is amazing about this is that it doesn't use any LEN or RIGHT$ or LEFT$ or MID$ (which I tried over and over LOL). 

Enjoy.

Code: (Select All)

'Thanks to ChatGPT for a little help figuring this out. I fixed the DIM numbers and removed the Function and made the code simpler.
'By SierraKen on Aug. 12, 2024
'I been wanting to make this since the 1990's! LOL

Dim values(13) As Integer
Dim symbols(13) As String

_Title "Numbers To Roman Numerals Converter"

Cls

start:

Input "Enter a number (1-3999): ", number

If number < 1 Or number > 3999 Then
    Print "Number out of range. Please enter a number between 1 and 3999."
Else

    values(1) = 1000: symbols(1) = "M"
    values(2) = 900: symbols(2) = "CM"
    values(3) = 500: symbols(3) = "D"
    values(4) = 400: symbols(4) = "CD"
    values(5) = 100: symbols(5) = "C"
    values(6) = 90: symbols(6) = "XC"
    values(7) = 50: symbols(7) = "L"
    values(8) = 40: symbols(8) = "XL"
    values(9) = 10: symbols(9) = "X"
    values(10) = 9: symbols(10) = "IX"
    values(11) = 5: symbols(11) = "V"
    values(12) = 4: symbols(12) = "IV"
    values(13) = 1: symbols(13) = "I"

    romanNum$ = ""
    num = number
    For i = 1 To 13
        While num >= values(i)
            romanNum$ = romanNum$ + symbols(i)
            num = num - values(i)
        Wend
    Next i

    Print "Roman Numeral: "; romanNum$
End If

Print: Print: Print
GoTo start:
Reply


Messages In This Thread
Numbers to Roman Numerals Converter - by SierraKen - 08-12-2024, 09:10 PM



Users browsing this thread: 7 Guest(s)