Computer Science I - Programming Assignment 4
Due Wednesday, November 18th
Summary
For this assignment you will create a web page called roman.html that
will convert Roman numerals to Arabic numerals (the ones we normally use as numbers)
and vice versa (to use a Latin phrase).
It should look something like this:
For this assignment Roman numerals are defined as follows:
- M is 1000
- D is 500
- C is 100
- L is 50
- X is 10
- V is 5
- I is 1
- All other numbers are expressed as sequences of the above symbols:
- MCLXVI is 1166
- XXXX is 40
- MM is 2000
- and so on
For an extra challege, you may use "modern" Roman numerals, which
Have different representations for a few numbers than the "simple" Roman
numerals (IV for 4, IX for 9, XL for 40, etc.).
Helpful Hints
- Going from Roman to Arabic numerals will require a loop that takes each character
in the Roman numeral string and adds it's numeric value to a running sum.
- Going from Arabic to Roman numerals is similar to the process of making change
(quarters first, then dimes, then nickels, then pennies).
Again, you will need a loop that repeatedly subtracts 1000, 500, 100, 50, etc. from the
Arabic Numeral and adds M, D, C, L, etc. to the Roman numeral string.
- If you want to try using "modern" Roman numerals, make sure you
get your code working with the "simple" Roman numerals first and save
a copy of your working code.
-
You might find the substring method for strings useful for finding
IV, IX, XL, etc.
Instructions for Handing In the Program
Please hand in the following:
- a printed copy of your completed roman.html in class on the due date
- an electronic copy of this file via FileZilla in the handin folder in your home directory on the CS server.
Do not put your assignment in your html directory as that is publicly viewable.