Write a program that converts a number entered in Roman numerals to a positive integer. Your program should consist of a class, romanType. An object of type romanType should do the following:
The template files required are on the study desk next to the assignment specifications. The three files (main.cpp, roman.h, romanimp.cpp) need to be extracted in the same directory.
The header file for the romanType class to be implemented. Do not modify the header file for the class. File located on the assignment section of the study desk.
//Roman Number Header file
//DO NOT MODIFY
#include < string>
using namespace std;
class romanType
{
public:
void setRoman(string);//Set the romaType to a new value as string(no error checking)
void setRoman(int);//Set the romanType to a new value with integer
void romanToPositiveInteger(); //convert the roman string to a number value
void printPositiveInteger() const;
void printRoman() const;
string getRoman();//Return the roman value as a string
int getValue();//return the roman value as a number
void inc();//increment the roman variable
void dec();//decrement the roman variable
void add(romanType);//add two romanType values
void add(int);//Add new integer value to existing romanType
//constructors
romanType();
romanType(string);
romanType(int);
private:
string intToRoman(int); //convert an integer value into roman string representation
string romanNum;
int num;
};
The integer values of the Roman numerals are:
M 1000
D 500
C 100
L 50
X 10
V 5
I 1
More details can be seen from the following link: https://en.wikipedia.org/wiki/Roman_numerals.
Main file to be compiled to test the implementation of the romanType class can be found on the study desk.
The main file has 3 top level functions that need to be implement for all the test to work.
//Top level functions to be implemented
romanType add(romanType, romanType);
romanType add(romanType, int);
void printTimesTable(romanType, romanType);
The output from the class run is captured below
Print the roman representation of the values
I
XXIV
XXXIII
Default romanType constructor with no parameter
Default romanType variable as Roman = I
Default romanType variable as number = 1
Setting the default romanType value to 44
Default romanType variable as Roman = XLIV
Default romanType variable as value = 44
Get roman and value from the string constructor
String constructor romanType variable as Roman = XXIV
String constructor romanType variable as value = 24
Get roman and value from the integer constructor
Number constructor romanType variable as Roman = XXXIII
Number constructor romanType variable as number = 33
Increment and Decrement on romanTypes
Increment class method on a romanType before XXXIII After call to class
method inc XXXIV
Decrement class method on a romanType before XXXIV After call to class
method dec XXXIII
Add using function method on romanTyes
Add two romanType using top level function XXIV plus XXXIII = LVII
Add using overloaded function method on romanTyes and integer
Add two romanType using top level function XXIV plus 12 = XXXVI
Using class method for addition of romanTypes XXIV plus XXXIII Result =
LVII
Using overloaded class method for addition of romanType and integer LVII
plus 12 Result = LXIX
Roman Times Table base 6 12 times
I * VI = VI
II * VI = XII
III * VI = XVIII
IV * VI = XXIV
V * VI = XXX
VI * VI = XXXVI
VII * VI = XLII
VIII * VI = XLVIII
IX * VI = LIV
X * VI = LX
XI * VI = LXVI
XII * VI = LXXII