Question: A) Begin by writing a program that converts a single Roman number in the range I (1) to IX (9) to Arabic form. The program

A)
Begin by writing a program that converts a single Roman number in the range I (1) to IX (9) to Arabic form. The program should read a single string from standard input and print the corresponding value on standard output.
Hint: Use an array of strings to represent the Roman units digits, organised so that the string index corresponds to the digit value. For example, the array would have the string IV at index position 4, and the string VII at index position 7. Then convert the input string by searching through the array until you find a match. The index where you find the match will be the digit value you need. Note that for reasons explained below, it's easiest to begin at the "9" end of the array and work downwards.
Extend the program so that it works correctly when the input consists of either lower case or upper case Roman letters. The simplest approach is to convert each character in the input word into uppercase before trying to find a match. Run a loop over the characters in the string, using the index operator ([]) to access each character and the toupper function (you'll need to include the cctype header file) to get the uppercase value.
B)
Extend the program so that it can deal with single-digit numbers of any value. A single-digit number is one that consists only of thousands, hundreds, tens, or units. Thus LXX (70) and CD (400) are single-digit numbers, but XIV (14) and MC (1100) are not. Use the same approach as for units digits, but with 4 different arrays, one each for the thousands, hundreds, tens, and units digits. Try looking for thousands digits first, then for hundreds, and so on. When you find a match in one of the arrays, print the corresponding value and stop.
Extend the program so that it reads and converts all input numbers until end of file on standard input. You'll probably be able to do this simply by adding an appropriate "reading loop" around the code that reads a single line.
** please answer each part of question in seperate algoritthem so i can understand how from first step achieve to second step.
please note the language is C++
How would life be different if the Roman Empire was still alive in the computer age? For a start, computer programs would have to deal with input and output of numbers specified using a rather different scheme than the Arabic system we currently use. Your task is to write a Ctt program, roman, that reads numbers specified in Roman form, then writes the numbers translated into Arabic. The program should read from standard input and write to standard output. Input will consist of a series of lines each containing a number to be converted. For each input line, the program should write a line of output that consists of the converted number terminated with a newline. The program should continuously read input and write output until all input is processed. Automatic Testing This task is available for automatic testing using the name roman. You can run the demo using demo roman and you can test your work using try roman >When you're ready to submit your work, use handin roman >. If your source code consists of more than one file, you'll need to submit a zip file. Background Like the familiar Arabic scheme, Roman numbers are written in decimal form; a Roman number contains thousands, hundreds, tens, and units "digits". However, Roman numbers use strings of letters to represent each digit, with different letters used for the thousands, hundreds, tens, and units digits. Moreover, although Roman numbers are always written so that the thousands digit comes first and the units digit last, there is no way to write "zero"; you simply leave the digit out. Roman digits are written using the following letters, with each letter standing for a certain value: D or d five hundred L or fifty Vorv five M or m one thousand Corc one hundred Xorx: ten Iori one To represent digit values other than those above, digit letters are repeated; as a special case, digits 4 and 9 (and their corresponding higher place values) are written by prefixing the "5" and "10" letters with the "1" letter. The following table lists all valid Roman digits; note that the highest valid Roman number using this scheme is 3999 (MMMCMXCIX). thousands units Xxx IV DC LX VI VIII XC IX
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
