Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CSIS 3 5 2 ( Spring 2 0 2 4 ) Prof. Cabanela Assignment 1 : Evaluating Roman Numerals Due Wednesday, January 1 7 ,
CSIS Spring
Prof. Cabanela
Assignment : Evaluating Roman Numerals Due Wednesday, January at pm
This homework is based on Programming Exercise from the textbook although I sought to provide more hints here for how to do the problem.
Fxercise Tweaked: Write a program that converts a number entered in Roman numerals to a positive integer. Your program should consist of a class, say, xomanType. An object of type romanType should do the following:
a Store the number as a Roman numeral using method setRoman as well as in a constructor, which should initialized to a value of I if no value is given
b Convert and store the number as a positive integer automatically computed by calling method romanToInteger when the value of the Roman numeral is set either by the constructor or by setRoman
c Return the number as a Roman numeral using method getRoman or positive integer using method getInteger as requested by the user. The integer values of the Roman numerals are:
tableMDCLXVI
d Write a main that requests a roman numeral from the user and the reports the equivalent positive integer. Test your program using the following Roman numerals: MCMIXIX, MCXIV, CCCLIX, and MDCLXVI which should correspond to positive integers and
Now for some hints:
A Roman Reminder: In Roman values, the total value is obtained by summing the numerals. For example the year is written MMXXII that is However, if the Roman numeral preceding another Roman number in the sequence read from left to right is smaller than it it indicates we should subtract the smaller number from the larger number. So for example, while the year, the year would be written MMXXIV. We typically see this when we would otherwise repeat a value less than more than times. For example, could be written VIIII but traditionally it is written IX to avoid repeating the I four times. The exception to this is for numbers larger than since there is no Roman numeral greater than M you are allowed to repeat M as many times as you need to eg is MMMMMMMMM
Remember to #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started