Question: Your task is to write a C + + program that reads numbers specified in Roman form and then writes the numbers translated into Arabic.
Your task is to write a C program that reads numbers specified in Roman form and 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 has been processed.
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. 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.
M or m: one thousand
D or d: five hundred C or c: one hundred
L or l: fifty X or x: ten
V or v:five I or i: one
Roman digits are written using the following letters, with each letter standing for a certain value:
Thousands
Hundreds
Tens
Units
M
C
X
I
MM
CC
XX
II
MMM
CCC
XXX
III
CD
XL
IV
D
L
V
DC
LX
VI
DCC
LXX
VII
DCCC
LXXX
VIII
CM
XC
IX
To represent digit values other than those above, digit letters are repeated. As a special case, digits and and their corresponding higher place values are written by prefixing the and letters with the letter. The table above lists all valid Roman digits. Note that the highest valid Roman number using this scheme is or MMMCMXCIX.
Level : Arabic numbers into Roman
Begin by writing a program that reads in from standard input a whole number in Arabic notation what we think of as a normal number, such as etc. and converts the number into its Romannumeral equivalent.
Your program should read and convert all input numbers until end of file eof on standard input. You will probably be able to do this by simply adding an appropriate reading loop around the code that reads a single line.
Hint: use an array of strings to represent each of the sets of Roman digits, organised so that the string index corresponds to the digit value. For example, the array for the units digits would have the string IV at index position and the string "VII" at index position You can then convert the input string by retrieving strings from the array. The digit occurring in each position in the original number will give you the index of the string you need from each of the different arrays.
Level : Simple Roman Numbers into Arabic
Now extend your program so that it is also able to read in simple numbers in Roman numerals, and output the Arabic numeral notation for that number. By simple number, we mean a Roman number that is made up of only ones or tens or hundreds or thousands, up to our limit of as before. Examples would be:
DC Output:
X Output:
IX Output:
MM Output:
but examples like XIV and MC are not simple numbers
Ensure the program works correctly when the input consists of lower case or upper case Roman letters or a mix 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 indexsubscript operator to access each character and use the toupper function you may need to include the cctype header file to get the corresponding uppercase value.
Also note that your program should still be able to solve Level Use the first character in the input word to decide which way to convert. If it is an Arabic digit, convert as much as possible of the word to Roman. If it is a Roman digit letter, convert as much as possible to Arabic. If it is neither, output zero. You can use the same digit arrays to convert both to and from Roman numbers.
PLEASE READ THIS Hi there are levels of the question, I want a single c code from level to level the first two levels and the background information is written and the information about level and level is in the first image, i have also attache the ss of the output which i got and what i want this time for making my code work, please help me because all the codes you sent me earlier did not gave a proper soulution, please help me this time, please check the output which you get then only send the answer. Thank you, I hope I will get the right solution this time.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
