hey guys. I'm working on this assignment for an online class. almost done, except i'm not getting the correct results. i'm at the point where i've been staring at the code for too long so i thought i'd try here. this isnt the whole thing, just the exact part i'm working on right now. converting roman numerals to decimals. "CD" comes up as 600 when it's 400.

Code:

#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
string input;
class romanType
{
public:
int number;
void convertRoman();
};
int main()
{
romanType myType;
cout << "Please enter a Roman number." << endl;
cin >> input;
myType.convertRoman();
}
void romanType::convertRoman(){
int output = 0;
int n = 0;
for (n = 0; n != input.length(); n++)
{
char p;
if (n > 0)
p = input[n - 1];
else
p = input[n];
if (input[n] == 'M' || input[n] == 'm')
output = output + 1000;
if (input[n] == 'D' || input[n] == 'd')
{
if (p == 'C' || p == 'c')
output = output + 400;
else
output = output + 500;
}
if (input[n] == 'C' || input[n] == 'c')
{
if (p == 'X' || p == 'x')
output = output + 90;
else
output = output + 100;
}
if (input[n] == 'L' || input[n] == 'l')
{
if (p == 'X' || p == 'x')
output = output + 40;
else
output = output + 50;
}
if (input[n] == 'X' || input[n] == 'x')
{
if (p == 'I' || p == 'i')
output = output + 9;
else
output = output + 10;
}
if (input[n] == 'V' || input[n] == 'v')
{
if (p == 'I' || p == 'i')
output = output + 4;
else
output = output + 5;
}
if (input[n] == 'I' || input[n] == 'i')
output = output + 1;
if (input[n] == 'M' || input[n] == 'm' || input[n] == 'D' || input[n] == 'd' || input[n] == 'C' || input[n] == 'c' || input[n] == 'L' || input[n] == 'l' || input[n] == 'X' || input[n] == 'x' || input[n] == 'V' || input[n] == 'v' || input[n] == 'I' || input[n] == 'i')
cout << "Thanks!" << endl;
else
cout << "Please enter capital letters consisting of only M, C, D, L, X, V, and I." << endl;
}
cout << output << endl;
}