Roman numerals is a number system used in ancient Rome to represent integer numbers. In this system, seven letters are used. The letters and their values are shown in the following table.
Note that there is no zero in the table since ancient Roman do not have the concept of zero. An integer represented in Roman numerals usually take more than one letter. In this case, the value is usually additive from left to right unless the letter on the immediate right has a larger value. In the latter case, the smaller value of the left letter is subtracted from the larger value of the right letter. Using this simple rule, some typical numbers are shown in the table below.
Please write a C program to read an integer represented in Roman Numerals and then print out it’s decimal value. Examples of program execution are shown below.
Input a Roman Numeral: MMXIV
The value is: 2014
Input a Roman Numeral: MCMXCIX
The value is: 1999
Create a directory lab04 and use it as the working directory.
Name your program source file as lab04.c.
The first few lines of your program should be comments as the following.
/* EE231002 Lab04. Deciphering Roman Numerals ID, Name
After finishing editing your source file, you can execute the following command to compile it,
$ gcc lab04.c
If no compilation errors, the executable file, a.out, should be generated, and you can execute it by typing
After you finish verifying your program, you can submit your source code by
$ ee231002/bin/submit lab04 lab04.c
If you see a ”submitted successfully” message, then you are done. In case you want to check which file and at what time you submitted your labs, you can type in the following command:
$ ee231002/bin/subrec lab04
It will show the last few submission records.