Question: 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
This homework is based on Programming Exercise from the textbook although I sought to provide more hints here for how to do the problem.
Exercise Tweaked: Write a program that converts a number entered in Roman numerals to a positive integer. Your program should consist of a class, say, romanTYpe. 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:
tableMDCIXVI
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: MCMLXIX, 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 MMXXIII 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 MMMMMMMM
Remember to #include
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
