Programming Language: C++ I need the codes for extRomanType.cpp, extRomanType.h, main.cpp, romanType.cpp, romanType.h // I will definitely rate and give thumbs up. Here are the initial codes, this...



Programming Language: C++


I need the codes for
extRomanType.cpp, extRomanType.h, main.cpp, romanType.cpp, romanType.h


// I will definitely rate and give thumbs up.



Here are the initial codes, this might help in building the program.



main.cpp



#include 



#include "extRomanType.h"


using namespace std;


int main()

{

    extRomanType num1("XXXIV");

    extRomanType num2("XV");

    extRomanType num3;



    cout <><><>

    cout <><><>

    cout <><><>

    cout <><><>



    cout <><><>

    cout <><><>



    cout <>

    cin >> num1 >> num2;

    cout <>



    cout <><><>

    cout <><><>



    num3 = num2 * num1;

  cout <><><>

 //   num3.romanToPositiveInteger();

 //   num3.printDecimal();

    cout <>



    cout <><><>

 //   num3.romanToPositiveInteger();

 //   num3.printDecimal();

    cout <>



    cout <><><>

  //  num3.romanToPositiveInteger();

 //   num3.printDecimal();

    cout <>



    cout <><><>

    cout <><><>

    cout <><><>

    cout <><><>

    cout < "num1   num2 ="">< num1 ><>



    cout <><><>

    cout <><><>





    return 0;

}



romanType.h




//Roman Num Header file


#include 

using namespace std;



class romanType

{

public:

    void setRoman(string);

    void romanToPositiveInteger();

    void printPositiveInteger() const;

    void printRoman() const;

    romanType();

    romanType(string);



private:

    string romanNum;

    int num;

};



romanType.cpp





//Roman Number Implementation file



#include 

#include 

#include "romanType.h"


using namespace std;



void romanType::printPositiveInteger() const

{

    cout <>

}



void romanType::printRoman() const

{

    cout <>

}



void romanType::setRoman(string rString)

{

    romanNum = rString;

    romanToPositiveInteger();

}



void romanType::romanToPositiveInteger()

{

    int sum = 0;

    int length =  romanNum.length();

    int i;


  int previous = 1000;



    for (i = 0; i <>

    {

         switch (romanNum[i])

         {

         case 'M':

            sum += 1000;

            if (previous <>

                sum -=  2 * previous;

            previous = 1000;

            break;

         case 'D':

             sum += 500;

            if (previous <>

                sum -= 2 * previous;

            previous = 500;

            break;

         case 'C':

             sum += 100;

            if (previous <>

                sum -= 2 * previous;

            previous = 100;

            break;

         case 'L':

             sum += 50;

            if (previous <>

                sum -= 2 * previous;

            previous = 50;

            break;

         case 'X':

             sum += 10;

            if (previous <>

                sum -= 2 * previous;

            previous = 10;

            break;;

         case 'V':

             sum += 5;

            if (previous <>

                sum -= 2 * previous;

        previous = 5;

            break;

         case 'I':

            sum += 1;

            previous = 1;

        }

    }



    num = sum;

}



romanType::romanType()

{

    romanNum = 'I';

    num = 1;

}



romanType::romanType(string rString)

{

    romanNum = rString;

    romanToPositiveInteger();

}






Arithmetic with Roman Numerals<br>Instructions<br>In programming Exercise 6 in Chapter 10, we defined a class romanType to implement Roman<br>numbers in a program. In that exercise, we also implemented a function,<br>romanToPositiveInteger , to convert a Roman number into its equivalent positive integer.<br>Modify the definition of the class romanType so that the member variables are declared as<br>protected . Furthermore, overload the stream insertion and stream extraction operators for easy<br>input and output. The stream insertion operator outputs the Roman number in the Roman format.<br>Also, include a member function, positiveIntegerToRoman , that converts a positive integer to<br>an equivalent Roman number format. Write the definition of the member function<br>positiveIntegerToRoman<br>For simplicity, we assume that only the letter I can appear in front of another letter and that it<br>appears only in front of the letters V and X. For example, 4 is represented as IV, 9 is represented as<br>IX, 39 is represented as XXXIX, and 49 is represented as XXXXIX. Also, 40 willI be represented as<br>XXXX, 190 will be represented as CLXXXX, and so on.<br>1/2<br><><br>

Extracted text: Arithmetic with Roman Numerals Instructions In programming Exercise 6 in Chapter 10, we defined a class romanType to implement Roman numbers in a program. In that exercise, we also implemented a function, romanToPositiveInteger , to convert a Roman number into its equivalent positive integer. Modify the definition of the class romanType so that the member variables are declared as protected . Furthermore, overload the stream insertion and stream extraction operators for easy input and output. The stream insertion operator outputs the Roman number in the Roman format. Also, include a member function, positiveIntegerToRoman , that converts a positive integer to an equivalent Roman number format. Write the definition of the member function positiveIntegerToRoman For simplicity, we assume that only the letter I can appear in front of another letter and that it appears only in front of the letters V and X. For example, 4 is represented as IV, 9 is represented as IX, 39 is represented as XXXIX, and 49 is represented as XXXXIX. Also, 40 willI be represented as XXXX, 190 will be represented as CLXXXX, and so on. 1/2 <>
Extending the romanType class<br>Instructions<br>Derive a class extRomanType from the class romanType to do the following: In the class<br>extRomanType , overload the arithmetic operators +, - , * , and / so that arithmetic<br>operations can be performed on Roman numbers. Also, overload the pre- and post-increment and<br>decrement operators as member functions of the class extRomanType .<br>To add (subtract, multiply, or divide) Roman numbers, add (subtract, multiply, or divide,<br>respectively) their positive integer representations and then convert the result to the Roman<br>number format. For subtraction, if the first number is smaller than the second number, output a<br>message saying that,

Extracted text: Extending the romanType class Instructions Derive a class extRomanType from the class romanType to do the following: In the class extRomanType , overload the arithmetic operators +, - , * , and / so that arithmetic operations can be performed on Roman numbers. Also, overload the pre- and post-increment and decrement operators as member functions of the class extRomanType . To add (subtract, multiply, or divide) Roman numbers, add (subtract, multiply, or divide, respectively) their positive integer representations and then convert the result to the Roman number format. For subtraction, if the first number is smaller than the second number, output a message saying that, "Because the first number is smaller than the second, the numbers cannot be subtracted". Similarly, for division, the numerator must be larger than the denominator. Use similar conventions for the increment and decrement operators. Write a main() to test your class. FILETREE -~/sandbox required files/codes A extRomanType.cpp A extRomanType.h A main.cpp A romanType.cpp A romanType.h
Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here