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:

  • Store the number as a Roman numeral.
  • Convert and store the number as a positive integer.
  • Print the number as a Roman numeral
  • Print the number as a positive integer
  • Have a default parameter less constructor
  • Constructor without parameters
  • Constructor which accepts a string
  • Constructor which accepts an integral value
  • Method to increment the romanType class by one
  • Method to decrement the romanType class by one
  • Method that adds to a romanTypes with romanType parameter
  • Method that adds to a romanTypes with integer parameter
  • Method to retrieve the romanType as string representation
  • Method that retrieves the value of the romanType

Files

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
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.