Answered step by step
Verified Expert Solution
Link Copied!

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 352(Spring 2024)
Prof. Cabanela
Assignment 1: Evaluating Roman Numerals Due Wednesday, January 17,2024 at 11 pm
This homework is based on Programming Exercise 10-6 from the textbook although I sought to provide more hints here for how to do the problem.
Fxercise 10-6(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:
\table[[M,1000],[D,500],[C,100],[L,50],[X,10],[V,5],[I,1]]
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 1969,1114,359, and 1666.
Now for some hints:
A Roman Reminder: In Roman values, the total value is obtained by summing the numerals. For example the year 2023 is written MMXXII (that is 1000+1000+10+10+1+1+1). 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 2024 would be written MMXXIV. We typically see this when we would otherwise repeat a value (less than 1000) more than 3 times. For example, 9 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 4000 since there is no Roman numeral greater than M, you are allowed to repeat M as many times as you need to (e.g.9000 is MMMMMMMMM).
Remember to #include
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions