Would you all help me develop this quick and fast prgram?

I dont know how to start :l


Roman Numeral Converter
Write a program that displays the roman numeral equivalent of any decimal number
between 1 and 20 that the user enters. The roman numerals should be stored in an array of
strings and the decimal number that the user enters should be used to locate the array element holding the roman numeral equivalent. The program should have a loop that allows
the user to continue entering numbers until an end sentinel of 0 is entered.
Input validation: Do not accept scores less than 0 or greater than 20.

I would really appreciate
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
std::string generateRoman(int n)
{
    //For you to write
}

int main()
{
    std::string romans[21];
    for(int i(1); i < 21; ++i)
        romans[i] = generateRoman(i);
    int x;
    std::cout << "Enter number in [0, 20]: ";
    while(std::cin >> x) {
        if(x < 0 || x > 20) {
            std::cout << "Invalid number! Enter number in [0, 20]: ";
            continue;
        }
        if (x == 0)
            break;
        std::cout << x << " in roman is: " << romans[x] << std::endl;
    }
}
Last edited on
that function will probably end up as 20 case statements, unfortunately.
May as well just initialize the array with the 20 roman numerals.
Topic archived. No new replies allowed.