home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
education
/
b
/
roman
/
!Roman
/
ReadMe
< prev
next >
Wrap
Text File
|
1992-05-07
|
2KB
|
69 lines
Programmer's Challenge Roman Numerals
By Ian Knox (Account 22) 28/03/90
Two arrays are dimensioned one to store the cardinal Roman
Numeral characters and the other for their decimal equivalent.
Data is read into these two arrays.
The program prompts you to enter a number and then traps the
high and low limits as there are no Roman Numerals for numbers
less than one and numbers greater than 5000 look silly.
The selected number is printed on the screen.
The program generates each Roman Numeral or Numeral pair along
with its decimal equivalent. These consist of the following
M = 1000 Cardinal Numeral
IM = 999
VM = 995
XM = 990
LM = 950
CM = 900
D = 500 Cardinal Numeral
ID = 499
VD = 495
XD = 490
LD = 450
CD = 400
C = 100 Cardinal Numeral
IC = 99
VC = 95
XC = 90
L = 50 Cardinal Numeral
IL = 49
VL = 45
XL = 40
X = 10 Cardinal Numeral
IX = 9
V = 5 Cardinal Numeral
IV = 4
I = 1 Cardinal Numeral
There are a few other numeral pairs generated but these are
ignored because their value is of a Cardinal Numeral and these
are as follows.
DM = 500 (D)
LC = 50 (L)
VX = 5 (V)
As listed the Numerals and Numeral Pairs are used in decreasing
order in PROCcalc as variables number% (decimal equivalent) and
roman_equivalent$. The local variable Y% is set to the value X%
(the uncalculated remainder of the selected number) and the
subtraction of number%. If Y% has a value greater than zero then
the character(s) is printed adding to the numeral string of
characters. The variable X% has number% subtracted from it giving
a new uncalculated remainder. This is repeated until Y% is less
than zero when the procedure is exited.
By the time all the numeral and numeral pairs have been used the
complete Roman Numeral is displayed on the screen next to its
decimal equivalent.