Write a C++ class implementing Roman numerals. Make sure it compiles and has no
ID: 3627493 • Letter: W
Question
Write a C++ class implementing Roman numerals. Make sure it compiles and has no warnings. I'd really appreciate it. Thanks!
The subtractive Roman numeral notation commonly in use today was used only rarely during the time of the Roman Republic and Empire. For ease of calculation, the Romans most frequently used a purely additive notation in which a number was simply the sum of its digits (4 equals IIII in this notation, not IV). Each number starts with the digit of highest value and ends with the digit of smallest value. This is the notation you will use in this program.
Values of the Roman digits you must recognize are as follows:
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
Thus, the number MDCCCCLXXXXVI represents 1996, because 1996 really consists of:
1000 + 500 + 100 + 100 + 100 + 100 + 50 + 10 + 10 + 10 + 10 + 5 + 1.
M D C C C C L X X X X V I
The constructor will take a string giving the object’s Roman numeral value.
Two functions should be implemented which return the object’s value as a Roman numeral string and as an integer.
Four other functions will perform addition, subtraction, multiplication and division with another Roman object passed as a parameter, returning a third Roman object whose value is the result of that calculation. For example, a Roman object constructed with “XVI” passed another Roman object constructed with “VIII” to the division function would return a Roman object constructed with “II”.
Your implementation should be broken into three files: one to define the roman class, roman.h, one to implement the class, roman.cpp and one to create and use Roman class objects, romanMain.cpp (which will contain the main function).
Submit all three files as your solution to this problem.
Explanation / Answer
IV AND another 2?
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.