Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What's wrong with this code? onvert between Arabic, base ten numbers, and Roman numerals. The Roman number system has the digits I, V, X, L,

image

What's wrong with this code?

image

image

onvert between Arabic, base ten numbers, and Roman numerals. The Roman number system has the digits I, V, X, L, C, D, and M. Numbers are formed according to the following rules: 1. Only numbers up to 3,999 are represented. 2. As in the decimal system, the thousands, hundreds, tens, and ones are expressed separately. (In other words, it's a positional number system.) The numbers 1 to 9 are expressed like the table shown at the right. As you can see, a I preceding a V or X is subtracted from the value, and you can never have more than three I's in a row. Tens and hundreds are done the same way, except that the let- ters X, L, C, and C, D, M are used instead of I, V, X respectively. I II III IV V VI VII VIII IX 1 2 3 4 5 6 7 8 9 The toRoman() function accepts a decimal number such as 1978, and converts it to a string containing the Roman numerals "MCMLXXVIII". An invalid number (0, a negative number, or a number greater than 3,999) returns the string "OUT OF RANGE". string digit(int n, const string symbols); string ones (int n) { return digit(n, "IVX"); } string tens(int n) { return digit(n, "XLC"); } string hundreds(int n) { return digit(n, "CDM"); } Do make things easier for you, I've already written a regular console program that converts integers to Roman numerals. You'll find it in the file decToRoman.txt. Notice that the program is long and complex. Decompose toRoman () using the following four functions, which will be tested separately as well. C

Step by Step Solution

3.52 Rating (149 Votes )

There are 3 Steps involved in it

Step: 1

To convert between Arabic base ten numbers and Roman numerals you can use the provided functions digit ones tens and hundreds These functions will hel... 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

Java Concepts Late Objects

Authors: Cay S. Horstmann

3rd Edition

1119186714, 978-1119186717

More Books

Students also viewed these Programming questions

Question

How have our views of gender changed in recent history?

Answered: 1 week ago