Can't Get Answer to Output!

So the problem is to input a roman numeral and output its decimal. I wrote a function with all of the parameters, and I can get the roman numeral input, but I can't get the decimal to output. What did I do wrong?

#include <iostream>
using namespace std;

int calcDecimal(char roman);

int main()
{
char roman;
int decimal = 0;

cout << "Please enter in a Roman Numeral." << endl;
cin >> roman;
calcDecimal(roman);
cout << decimal << "\n" << endl;

return 0;
}

int calcDecimal(char roman)
{
int decimal = 0;

do
{
if (roman == 'M' || 'm')
decimal = decimal + 1000;
else if (roman == 'D' || 'd')
{
roman = cin.peek();
if (roman == 'D' || 'd')//prevents repeat
{
cerr << "The Roman Numeral 'D' can't be repeated.\n"
<< endl;
exit(1);
}
else
decimal = decimal + 500;
}
else if (roman == 'C' || 'c')
{
roman = cin.peek();
if (roman == 'M' || 'm' || 'D' || 'd')//subtraction case
decimal = decimal - 100;
else
decimal = decimal + 100;

}
else if (roman == 'L' || 'l')
{
roman = cin.peek();
if (roman == 'L' || 'l')//prevents repeat
{
cerr << "The Roman Numeral 'L' can't be repeated.\n"
<< endl;
exit(1);
}
else
decimal = decimal + 50;
}
else if (roman == 'X' || 'x')
{
roman = cin.peek();
if (roman == 'C' || 'c' || 'L' || 'l')//subtraction case
decimal = decimal - 10;
else
decimal = decimal + 10;
}
else if (roman == 'V' || 'v')
{
roman = cin.peek();
if (roman == 'V' || 'v')//prevents repeat
{
cerr << "The Roman Numeral 'V' can't be repeated.\n"
<< endl;
exit(1);
}
else
decimal = decimal + 5;
}
else if (roman == 'I' || 'i')
{
roman = cin.peek();
if (roman == 'X' || 'x' || 'V' || 'v')//subtraction case
decimal = decimal - 1;
else
decimal = decimal + 1;
}
else
{
cout << "You did not enter an appropriate character." << endl;
exit(1);
}
}while (cin.get(roman));

return decimal;

}
Topic archived. No new replies allowed.