#include <iostream>
#include <string>
using namespace std;
class rom2dec
{
public: void roman();
int convert();
void print();
void get();
private: int M, D, C, L, X, V, I;
char romanNumeral;
};
void rom2dec::roman()
{
M = 1000;
D = 500;
C = 100;
L = 50;
X = 10;
V = 5;
I = 1;
}
int rom2dec::convert()
{
if(romanNumeral == 'I' || 'i')
{ cout << 1; }
else if(romanNumeral == 'V' || 'v')
{ cout << 5; }
else if(romanNumeral == 'X' || 'x')
{ cout << 10; }
else if(romanNumeral == 'L' || 'l')
{ cout << 50; }
else if(romanNumeral == 'C' || 'c')
{ cout << 100; }
else if(romanNumeral == 'D' || 'd')
{ cout << 500; }
else if (romanNumeral == 'M' || 'm')
{ cout << 1000; }
else if(romanNumeral != 'I' && romanNumeral != 'i' && romanNumeral != 'V' && romanNumeral != 'v' && romanNumeral != 'X' && romanNumeral != 'x' && romanNumeral != 'L' && romanNumeral != 'l' && romanNumeral != 'C' && romanNumeral != 'c' && romanNumeral != 'D' && romanNumeral != 'd' && romanNumeral != 'M' && romanNumeral != 'm')
{ cout << "Error! Not a valid value!" << endl; }
return romanNumeral;
}
void rom2dec::print()
{ cout << romanNumeral << endl; }
void rom2dec::get(){ }
int main()
{
char romanNumeral;
cout << "Please enter a number in Roman numerals to be converted: " << endl;
cin >> romanNumeral;
return 0;
}
I get no errors when I build the program, but when I debug and try to convert a Roman numeral to a decimal I get no decimal. All suggestions welcome and if there is a simpler way to write the last else if please let me know. Thanks.