The Five Steps
Understand the problem
What is this program supposed to do?
-
The program is supposed to read the next roman number from the input.
The main objective is to write the function get_roman(), but we will
also need a driver to test it.
What kind of information is it given?
(What is the input?)
-
The number is to be read from the standard input, and consists of
roman digits:
- M = 1000
- D = 500
- C = 100
- L = 50
- X = 10
- V = 5
- I = 1
What kind of results is it to produce?
(What is the output?)
-
The function should return the integer representaion of the
roman number. The driver should just print the result.
What formulas or techniques will be needed?
-
At first, the method seems straightforward; we just add up the
values associated with each roman digit. However, roman numbers have
an added twist - prefix digits. If a digit with a lower value
preceeds a digit with a larger value, the lower value should be subtract
rather than added.
Write an algorithm for solving the problem
Translate the algorithm into a programming language (like C)
Test the program
to Overview.