#include <iostream>
using namespace std;
//function protoytypes
int roman2integer();
bool isValidRoman(string & r);
int findIt(char ch);
int main()
{
int choice;
do{
switch(choice)
{
case 1: roman2integer();
break;
case 2: //integer2roman();
break;
case 3: //quit=true;
break;
default:
return 0;
};
}while( );
return 0;
}
///////////////////////////////////////////////////////////////////////////////
int roman2integer()
{
string roman;
int integerValue=0;
bool valid;
//SIZE=roman.lengeth();
do{
cout << "Enter in a number in roman numerals: ";
cin >> roman;
valid = isValidRoman(roman);
}while( );
for(int x=0; x<SIZE; x++)
{
if(findIt(roman[x]) < (findIt(roman[x+]))
integerValue-=findIt(roman[x]);
else
integerValue+=findIt(roman[x]);
}
return integerValue;
}
///////////////////////////////////////////////////////////////////////////////
bool isValidRoman(string & r)
{
for(int x=0; x < r.length(); x++)
{
r[x] = toupper(r[x]);
switch(r[x])
{
case 1: 'I';
break;
case 2: 'V';
break;
case 3: 'X';
break;
case 4: 'L';
break;
case 5: 'C';
break;
case 6: 'D';
break;
case 7: 'M';
break;
default:
return false;
};
}
}
///////////////////////////////////////////////////////////////////////////////
int findIt(char ch)
{
if(ch=='I')
return 1;
if(ch=='V')
return 5;
if(ch=='X')
return 10;
if(ch=='L')
return 50;
if(ch=='C')
return 100;
if(ch=='D')
return 500;
if(ch=='M')
return 1000;
}
I know my codes has errors which i will fix but if u wanna help me fix them that would be great but in my validating function im having a hard time figuring out what code to write so that the roman numeral rules are validated so i need help with that if anyone is willing to.