Roman Numeral Calculator

This is a software development task and an implementation task.

Roman numerals continue to be used for certain limited purposes such as copyright dates. The symbols used are I=1, V=5, X=10, L=50, C=100, D=500 and M=1000.

One definition of Roman numbers is

  • the letters must be in descending order of value,
  • the value of the number is the sum of all the letters,
  • a letter must not be repeated if it can be replaced by another letter.

This is known as the additive rule and is the only rule to be used in this question.

Note that Roman numbers are always integers and cannot have fractional values. For example

  • MCX = 1000 + 100 + 10 = 1110
  • MXC is invalid because of wrong order
  • IIII = 1 + 1 + 1 + 1 = 4
  • IIIII is invalid because it can be replaced with V

A manufacturing company wishes to make a new calculator that allows a user to input two numbers using Roman numerals and displays the numbers in both Roman and Arabic decimal forms. The calculator then allows a user to add or subtract the two numbers and again displays the result in both Roman and Arabic decimal forms.

The calculator must

  • allow a user to enter two numbers in Roman numerals, according to the additive rule, each up to a maximum value of MMMM (4000),
  • prevent the user entering an invalid Roman numeral,
  • display the numbers entered in both Roman numerals and in their Arabic decimal equivalent,
  • allow the user to enter an operator for addition or subtraction,
  • prevent the result of a subtraction being zero or a negative number,
  • display the result of the calculation in both Roman and Arabic decimal forms,
  • allow the user to clear all displays.

The company wishes to use a simulation of this calculator so that the user interface can be tested.

You should use a high level language to complete the following tasks. State the language and version
you use.

(a) Design and implement a user interface that can be used to test the above facilities.

Provide hard copy evidence of your design. [8]

(b) Write a function that has, as a parameter, an already validated Roman number and returns its Arabic decimal equivalent.

Provide hard copy of your function code, which should be fully annotated.

Write a short program to test your function. Use a Roman number that contains at least three different Roman numerals.

Provide hard copy evidence of your test. [5]

(c) Write a function that has, as a parameter, an Arabic decimal number and returns its Roman number equivalent.

Provide hard copy of your function code, which should be fully annotated.

Write a short program to test your function. Use an Arabic decimal number that converts to a Roman number containing at least three different Roman numerals.

Provide hard copy evidence of your test. [5]

(d) Write a program that will enable your simulated calculator to add and subtract two Roman numbers. Your program must use the interface and the two functions you have created in (a), (b) and (c).

Provide hard copy of your program code, which should be fully annotated. [11]

(e) Provide a table to show data suitable for testing the program you have written in (d). The table should show at least six different tests. In each case you should indicate the reason for the test, the data to be used and the expected result.

Provide hard copy evidence showing the use of your test data. Any error messages should appear on the calculator’s interface. [12]

This task was worth 41 Marks and should take approximatly 22.5 hours.  It was a software development task and an implementation task that orginally appeared in OCR 2507 Task 3 Jun 2006.  All rights and copyright to OCR.  Please refer to the OCR Copyright Statement for further information.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.