- #1
neo programmer
- 4
- 0
In speed trials experienced operators of the abacus outperform western-style
calculator users. Here we will teach the computer how to do basic arithmetic
in the style of an early calculating machine, the Roman abacus, but it is
unlikely to make the calculation any faster for the computer! The Roman
numbering system used seven basic symbols
Roman Numeral I V X L C D M
Decimal Equivalent 1 5 10 50 100 500 1000
Using these numerals numbers were represented by running the number of
required symbols together in descending value. For example,
XXXXVIII is 48
The Roman abacus had a row of beads for each symbol. So 48 is represented
as shown below. By using the V, L and D symbols, only a maximum of four
beads per symbol were required to represent any number up to 4999 which
was more than enough for day-to-day use.
M
D
C
L
X • • • •
V •
I • • •
To add to roman numbers using this abacus is both very simple and extremely
efficient. For example to add 2738 and 1524 we begin by coding the numbers
on the abacus
M • • M •
D • D •
C • • C
L • L
X • • • X • •
V V
I • • • I • • • •
2783 1524
Now all the beads are placed together, giving
M • • •
D • •
C • •
L •
X • • • • •
V
I • • • • • • •
All that remains is to perform a carry operation for each symbol. For symbols
I, X, and C, whenever we have five beads then we must add one bead to the
next symbol above and remove the five beads from the symbol in question.
For symbols, V, L, and D we do the same whenever two or more beads are
present. There is no carry operation for M since this is the highest symbol.
So, for our example we begin with I, counting 7 beads. We remove five beads
from I and add one bead to V. For V we have only one bead, so we do nothing.
For X we have five beads, and so we remove all five beads and add one to L.
We now have two beads under L and so we remove these and add one to C.
Only 3 beads are counted under C and so we do nothing. The two beads under
D are removed and one is added to M. All that remains is to read off the
result.
M • • • •
D
C • • •
L
X
V •
I • •
MMMMCCCVII = 4307
Write a program that performs Roman abacus addition. Store the number of
beads under each symbol in a single element of a 1-dimensional array. By
creating a separate array for each complete number add the two numbers
using the procedure outlined.
Allow the user to enter the 2 decimal numbers to be added, which are to be
first converted to Roman form and stored into the two arrays. Your program is
to provide a graphical representation of the input numbers on an abacus,
similar in form to that given above, and after each stage of the calculation. The
final state of the abacus should be shown along with the answer as a decimal
equivalent. Since the assignment tests for call by address use call by address
to pass information from these functions back to main.
Firstly, separate the problem into a number of functions, define an
input/output specification for each function (including main) and design a
flow-chart for each that implements its functionality.
calculator users. Here we will teach the computer how to do basic arithmetic
in the style of an early calculating machine, the Roman abacus, but it is
unlikely to make the calculation any faster for the computer! The Roman
numbering system used seven basic symbols
Roman Numeral I V X L C D M
Decimal Equivalent 1 5 10 50 100 500 1000
Using these numerals numbers were represented by running the number of
required symbols together in descending value. For example,
XXXXVIII is 48
The Roman abacus had a row of beads for each symbol. So 48 is represented
as shown below. By using the V, L and D symbols, only a maximum of four
beads per symbol were required to represent any number up to 4999 which
was more than enough for day-to-day use.
M
D
C
L
X • • • •
V •
I • • •
To add to roman numbers using this abacus is both very simple and extremely
efficient. For example to add 2738 and 1524 we begin by coding the numbers
on the abacus
M • • M •
D • D •
C • • C
L • L
X • • • X • •
V V
I • • • I • • • •
2783 1524
Now all the beads are placed together, giving
M • • •
D • •
C • •
L •
X • • • • •
V
I • • • • • • •
All that remains is to perform a carry operation for each symbol. For symbols
I, X, and C, whenever we have five beads then we must add one bead to the
next symbol above and remove the five beads from the symbol in question.
For symbols, V, L, and D we do the same whenever two or more beads are
present. There is no carry operation for M since this is the highest symbol.
So, for our example we begin with I, counting 7 beads. We remove five beads
from I and add one bead to V. For V we have only one bead, so we do nothing.
For X we have five beads, and so we remove all five beads and add one to L.
We now have two beads under L and so we remove these and add one to C.
Only 3 beads are counted under C and so we do nothing. The two beads under
D are removed and one is added to M. All that remains is to read off the
result.
M • • • •
D
C • • •
L
X
V •
I • •
MMMMCCCVII = 4307
Write a program that performs Roman abacus addition. Store the number of
beads under each symbol in a single element of a 1-dimensional array. By
creating a separate array for each complete number add the two numbers
using the procedure outlined.
Allow the user to enter the 2 decimal numbers to be added, which are to be
first converted to Roman form and stored into the two arrays. Your program is
to provide a graphical representation of the input numbers on an abacus,
similar in form to that given above, and after each stage of the calculation. The
final state of the abacus should be shown along with the answer as a decimal
equivalent. Since the assignment tests for call by address use call by address
to pass information from these functions back to main.
Firstly, separate the problem into a number of functions, define an
input/output specification for each function (including main) and design a
flow-chart for each that implements its functionality.