The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Need help with the attached question. C++. Thank you
20. C. d. In Programming Exercise 1 in Chapter 1, we defined a class
roman'rype to implement Roman numerals in a program. In that
exercise, we also implemented a fianction, roman'I'oDecimal, to con—
vert a Roman numeral into its equivalent decimal number. Modify the definition of the class roman'rype so that the data mem—
bers are declared as protected. Use the class string to manipulate
the strings- Furthermore, overload the stream insertion and stream
extraction operators for easy input and output. The stream insertion
operator outputs the Roman numeral in the Roman format. Also, include a member fianction, decimalToRoman, that converts the
decimal number (the decimal number must be a positive integer) to an
equivalent Roman numeral format- Write the definition of the member
fimction decimalToRoman. For simplicity, we aSSume that only the letter I can appear in front of
another letter and that it appears only in ernt 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 represemed as XXXXIX. Also, 40 will be represented
as moot, 19E!I will be represented as cm, and so on. 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 numerals- Also, overload the pre— and postincrement and
decrement operators as member fianctions of the class
extRomanType. To add (subtract, multiply, or divide) Roman numerals, add (subtract,
multiply, or divide, respectively) their decimal representations and then
convert the reSult to the Roman numeral format. For subtraction, if the
first number is smaller than the sec0nd 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 conven—
tions for the increment and decrement operators. Write the definitions of the fianctions to overload the operators
descnbed in part b. Write a program to test your class extRoman'rype.