Hello. I am working on a little side project for school and have no idea where to start with the error validation if the user of the program enters a invalid roman numeral like LXXC. I also need to test if a lower value character precedes a higher value character. It can be at most 2 values lower. here is what I have got so far:
This is a header file required by my instructor:
#include <string> //including string to read in a string of roman chars
using namespace std;
class romanType //starting to define custom class romanType
{
private:
string str;
static char chRoman;
static int intRoman;
This is the class definitions of the class functions in a separate cpp file as per the request of my instructor:
#include <iostream>
#include "roman.h"//this is the header file defined above
using namespace std;
void romanType::convertRoman()//starting the function definition of the func convertRoman
{
//entering loop to check each spot in the string for a numeral
for (int i = 0; i < str.length(); i++)
{
void romanType::printRoman()//starting printRoman Func
{
cout << "The Roman Value Was: "<< str << endl;
cout << "The Decimal Value Is: " << intRoman<< endl;
}//endiing func
romanType::romanType()//starting definition of constructor
{
chRoman='I';
intRoman=1;
}//ending constructor def
void romanType::storeRoman()//starting def of store roman func
{
char option;
do
{
cout<<"Enter the Roman Numeral in Capital letters (ex: CCXIX) : ";
cin >> str;
cout << endl;
romanType.convertRoman;//calling convertRoman Func
romanType.printRoman;//calling printRoman Func
cout << "Again? Y or y for yes or N or n for no";//asking if you want to iterate again
cin >> option;
cout << endl;
}while (option == 'Y'|| option =='y');
}//ending storeRoman func def
This is the main cpp file:
#include <iostream>
#include "roman.h"
using namespace std;
int main()//start of main function
{
romanType rtVar;//declaring a variable of the class type romanType
rtVar.storeRoman();//calling the store roman function
return 0;//ending main
}
Any help is greatly appreciated. Thanks in advance.