Numerals >> Roman Numerals

I'm Having trouble with this program, this simple program supposedly converts any number from 1 - 9999 to roman numerals. I thought up the algorithm and made it shown below, my problem's with an error that says.
"Invalid conversion from "const char" to 'char'"

can someone tell me what i'm doing wrong? or tell me what i can do to simply work around it?

This is in c++...

just making sure...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <string>
using namespace std;
int main ()
{
    int x , bconv, use;
    char ones[9] = {'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'};
    const char tens(9) = {"X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
    const char hunds[9} = {"C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
    const char thous[9} = {"M", "MM", "MMM", "Mv", "v", "vM", "vMM", "vMMM", "xM"};
    cout << "Enter an Arabic number: ";
    cin >> use;
    bconv = use;
    cout << endl;
    cout <<endl<<"Please wait..."<<endl<<endl;
    Sleep (3000)
    cout << "Your number ("<<use<<") in Roman numerals is:"<<emdl<<endl;
    cout << "\t";
    
    if (bconv >= 1000)
       {
               x = bconv/1000;
               if (x == 0)
                  {
                   continue;
                  }
                  else 
                  {
                       x--;
                       cout << thous[x];
                  }
               bconv = bconv - (x*1000);
       }
       else
           continue;
           
                  
    if (bconv >=  100)
       {
                x = bconv/100;
                if (x == 0)
                  {
                   continue;
                  }
                  else 
                  {
                       x--;
                       cout << hunds[x];
                  }
                2bconv = 2bconv - (x*100);
       }
       else
           continue;
           
    if (bconv >= 10)
       {
                x = bconv/10;
                if (x == 0)
                  {
                   continue;
                  }
                  else 
                  {
                       x--;
                       cout << tens[x];
                  }
                use = use - (x*10);
       {
       else
           continue;
    
    if (bconv >= 1)
       {
                x = bconv/1000;
                if (x == 0)
                  {
                   continue;
                  }
                  else 
                  {
                       x--;
                       cout << ones[x];
                  }
                use = use - (x*1);
       }
       else
           continue;
system ("pause");
return 0;
}
Last edited on
meanwhile i'm gonna brush up on my basics, they suck balls....
@taoden21

A few problems in your code.

1. chars are for single characters. You have multiples in your definitions.
2. Your arrays aren't all created correctly. They should have square brackets, [] , not parenthesis or a mixture of both.
3. At one point, you misspelled endl, as emdl.
4. You forgot a semicolon after Sleep (3000)

There are other problems, but we'll start with just these
1. can string be used in arrays then?

2-4. i kind of made this in a hurry we had a 2 hr time limit in thhinking of an algorithm, i'll look into it.

thanks someone replied atleast :D
i'll try refining this... and i'll try string arrays.
Last edited on
@taoden21

1. can string be used in arrays then?


Yes.

More help coming after we see your new, refined, program.
Topic archived. No new replies allowed.