Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that takes as input positive integers and converts them into then Roman numeral system equivalents. Requirements: Check for valid input - your

image text in transcribed

Write a program that takes as input positive integers and converts them into then Roman numeral system equivalents. Requirements: Check for valid input - your program should handle runtime exceptions caused by invalid input Your program should continue running until the user indicates a desire to quit Besides checking for input validity, your program must check for data out of bounds (as described below) and deal with it in a reliable manner (i.e. don't crash and don't produce bad output) The Roman numeral system uses the following symbols to represent the numeric values listed below: I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Numbers are formed according to the following rules: Only numbers greater than 0 and up to 3999 are represented (your program should check for this) As in the decimal system, the thousands, hundreds, tens and ones are expressed separately. The numbers 1 - 9 are expressed as: I 1 II 2 III 3 IV 4 V 5 VI 6 VII 7 VIII 8 IX 9 Generally, an 'I' preceding a 'V' or 'X' is subtracted from the second letter's value, and you never have morethan 3 'I's in a row. Tens and hundreds are done the same way, except that the letters X, L, C and C, D, M are used instead of I, V andX respectively. A sample program run: Hail Caesar! Enter a number to be converted to Roman numerals, or 0 to quit: 1978 That number is: MCMLXXVIII Enter a number to be converted to Roman numerals, or 0 to quit: quit is not valid input. Enter a number to be converted to Roman numerals, or 0 to quit: -5 -5 is out of bounds. Please enter a number between 1 and 3999. Enter a number to be converted to Roman numerals, or 0 to quit: 267 That number is: CCLXVII Enter a number to be converted to Roman numerals, or 0 to quit: 0 Beware the ides of March1

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

More Books

Students also viewed these Databases questions