$30.00
Description
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.
-
Letter
I
V
X
L
C
D
M
Value
1
5
10
50
100
500
1000
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.
-
Roman numerals
I
II
III
IV
V
VI
VII
VIII
IX
Decimal values
1
2
3
4
5
6
7
8
9
Roman numerals
X
XX
XXX
XL
L
LX
LXX
LXXX
XC
Decimal values
10
20
30
40
50
60
70
80
90
Roman numerals
C
CC
CCC
CD
D
DC
DCC
DCCC
CM
Decimal values
100
200
300
400
500
600
700
800
900
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.
-
./a.out
Input a Roman Numeral: MMXIV
The value is: 2014
-
./a.out
Input a Roman Numeral: MCMXCIX
The value is: 1999
Notes.
-
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
Date:
*/
1
-
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
$ ./a.out
-
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.
2