Your task is to write a C++ program to help you convert a number into roman numerals. Roman numerals are I for 1, V for 5, X for 10, L for 50, C for 100, D for 500, and M for 1000. Some numbers are formed by using a subtraction of Roman “digits”; for example, IV is 4, since V minus I is 4. Others are IX
for 9, XL for 40, XC for 90, CD for 400, and CM for 900. Your program will proceed in three parts:
1. Write a program that reads in a decimal number from the screen (using cin) and prints out
a simple Roman numeral. A simple Roman numeral does not use the subtraction rule. For
example, the simple Roman numeral for the number 493 will be CCCCLXXXXIII, and the simple
Roman numeral for the number 3896 will be MMMDCCCLXXXXVI. Your program should print the
entire Roman numeral on a single line, with no spaces between letters. You will need a while
loop in your program to print out the letters one at a time. Hint: Look at your minutes
program for ideas on how figure out which letter to print next.
2. Modify your program so that you print out all of the repeated letters in a single iteration
of your while loop. You will need to put a few for loops inside your while loop to do this
part. For example, if the Roman numeral you have to print out is MMMMXXX, the first part
iterated through your while loop seven times, one for each letter you were printing out. Now,
you want to iterate your while loop just twice, one for each kind of Roman numeral being
printed. Thus, the first iteration will print out MMMM, and the second will print out XXX. Your
final output will be MMMMXXX on a single line.
3. Modify your program to also handle subtractions. So now, 493 should give the answer CDXCIII,and 3896 should give the answer MMMDCCCXCVI.