Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The RomanNumeral Interface Begin by creating a Java interface to represent a Roman Numeral. Your interface will specify two methods one to return the value

The RomanNumeral Interface

Begin by creating a Java interface to represent a Roman Numeral. Your interface will specify two methods one to return the value of a Roman Numeral and another that returns a String representation of a numeral

The I, V, X, L, C, D, and M Classes

Create a class for each of the above numerals. These classes must all implement your RomanNumeral interface.

The RomanNumber Class

Create a class to model a RomanNumber, which is a valid series of Roman numerals.

You may implement the RomanNumber as either an array-of-RomanNumerals or an arraylist-of-RomanNumerals, your choice. Either one. If you choose an array, assume a maximum size of 20

Your class will have these methods:

A constructor

A method that adds a RomanNumeral to this RomanNumber (optional)

A method that converts a Roman Number to Arabic and returns it as an int

A method that converts an Arabic Number to Roman and returns it as a String

An overridden toString() method that returns a string representation of a Roman Number

The RomanNumeralCalculator Class

This class has a default constructor, and a compute method that performs an arithmetic operation (*,/,%,+,-) on two Roman Numbers and returns the result as a String in this general form:

XCIII XXXIX = LIV

93 39 = 54

Make sure your calculator class depends on the RomanNumber class only and not on any of the individual RomanNumeral classes

If you are doing this right, your calculator class should not have to be modified in any way if new Roman Numerals were to be invented in the future (e.g., maybe a symbol for 5000 or 10000). That is main benefit of using Java interfaces and precisely why they were invented.

The Test Class

Your test class will read and process arithmetic operations from a data file which I will supply. Each operation will have the left-hand Roman Number operand, an operator, and the right-hand Roman Number operand (separated by spaces)

Example: XCIII XXXIX

Additional Project Specifications

Assume correct input

All Roman Number inputs will be positive integers

All operations produce integer results

Although the result of an operation will never be 0 (the Romans did not have a zero numeral), it may be a negative integer

All output must include the input operation and the result in both Roman and Arabic Numerals, as returned by the calculator

E.g. XCIII XXXIX = LIV

93 39 = 54

The largest number we can represent using Roman Numerals is MMMCMXCIX (3999). If the result of a calculation is greater than 3999 (or less than -3999), simply print the message Roman Numeral Overflow"

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions