Write a C++ program that (1) asks the user to input a year number expressed in the Roman notation, (2) validates whether it is an existing and valid Roman number (i.e. (a) whether it does not consist of letters other than IVXCM, and (b) it does not have more than three such letters appearing one after the other) – if it is invalid for a reason (c) the program should issue a warning but still carry out the further processing, then (3) converts this year number into an ARABIC year number (for example it converts the year expressed as a ROMAN number (MCMXCIX) into Arabic 1999), and finally (4) displays the Arabic equivalent of this year. Hint: To achieve such a conversion, you need to know rules of formulation of Roman numbers. These rules are as follows: (1) Roman numbers are based on sum (or difference) of its components. They use the following components: M = 1000, D = 500, C = 100, L = 50 X = 10, V = 5, I = 1; (2) When a smaller component is placed in front of a larger component, it means that the smaller should be subtracted from the larger – e.g., Roman IX is 9 in Arabic, while Roman XC is 90 in Arabic. (3) ‘I’ can only be subtracted from V and X, but not from L or C. X can be subtracted from L and C, but not from M. Thus 99 is XCIX not IC! (4) For the validation purpose you need to know that with the exception for M, Roman numerals do not have more than three symbols grouped together, and do not contain letters other than I, V, X, L, C, D, M. Your program should include at least three functions to do the input, processing (conversion), and output. Also include a loop that will allow the user to repeat the whole program if he wants to. Test your program on the following Roman dates: MCMIX (1909), MCMXCVII (1997), MCMXCIX (1999), MMIX (2009). PLEASE add "//" every code wirtten to explain its use in the program. thank you! do the following conditions set and DO IT IN C++
Write a C++ program that (1) asks the user to input a year number expressed in the
Roman notation, (2) validates whether it is an existing and valid Roman number (i.e. (a)
whether it does not consist of letters other than IVXCM, and (b) it does not have more
than three such letters appearing one after the other) – if it is invalid for a reason (c) the
program should issue a warning but still carry out the further processing, then (3) converts
this year number into an ARABIC year number (for example it converts the year
expressed as a ROMAN number (MCMXCIX) into Arabic 1999), and finally (4) displays
the Arabic equivalent of this year.
Hint: To achieve such a conversion, you need to know rules of formulation of Roman
numbers. These rules are as follows:
(1) Roman numbers are based on sum (or difference) of its components. They use the
following components:
M = 1000,
D = 500,
C = 100,
L = 50
X = 10,
V = 5,
I = 1;
(2) When a smaller component is placed in front of a larger component, it means that the
smaller should be subtracted from the larger – e.g., Roman IX is 9 in Arabic, while Roman
XC is 90 in Arabic.
(3) ‘I’ can only be subtracted from V and X, but not from L or C. X can be subtracted from
L and C, but not from M. Thus 99 is XCIX not IC!
(4) For the validation purpose you need to know that with the exception for M, Roman
numerals do not have more than three symbols grouped together, and do not contain
letters other than I, V, X, L, C, D, M.
Your program should include at least three functions to do the input, processing
(conversion), and output. Also include a loop that will allow the user to repeat the whole
program if he wants to.
Test your program on the following Roman dates: MCMIX (1909), MCMXCVII (1997),
MCMXCIX (1999), MMIX (2009).
PLEASE add "//" every code wirtten to explain its use in the program. thank you! do the following conditions set and DO IT IN C++
Step by step
Solved in 4 steps with 4 images