Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++, as basic as possible, dont use another function, just put everything inside int main 2) Decimal to Roman Numeral Conversion The ancient Roman numbering

image text in transcribedimage text in transcribed

C++, as basic as possible, dont use another function, just put everything inside int main

2) Decimal to Roman Numeral Conversion The ancient Roman numbering system employed a sequence of letters to represent numeric values. Values were obtained by summing individual letter values in a left-to-right fashion. The value of individual Roman numerals is provided in the following list: I = 1 V = 5 X = 10 L = 50 C = 100 D = 500 M = 1000 In Roman numbers, larger numeral values generally appear before smaller values, and no single numeral may be repeated more than 3 times in a row. There are a few numbers that cannot be represented with these restrictions, so an additional rule was provided to deal with these cases: if a higher value numeral is preceded by a single smaller numeral, the smaller value is subtracted from the larger one. This rule is only applied to a small number of cases: IV (4), IX (9), XL (40), XC (90), CD (400) and CM (900). Using these simple rules, we can construct a method to convert an integer (decimal) value to a Roman number as follows: Step 1: If the value of the number is in [900,999) output CM If the value is in (500,899) output D If the value is in [400,499) output "CD" If the value is in (100,399) output "C" If the value is in (90,99) output XC" If the value is in (50,89) output "L" If the value is in [40,49) output "XL" If the value is in (10,39) output X If the value is 9, output IX If the value is in (5,8) output V If the value is 4, output IV If the value is in (1,3), output I Step 2: Subtract the value of the 1 or 2 letter sequence that was just output from the integer number value, producing a 'remainder.' For example, if the original number was 93, the program would have printed XC in Step 1, and then, in this step, subtracted 90 to get a remainder of 3, and then continued with 3 as the number. Step 3: Repeat the process until the remainder value is zero. Using this method, write a program that does the following: Reads in an integer value from 1 to 999, inclusive. Checks to make sure the input value is > and

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

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

Introduction to Languages and the Theory of Computation Solution

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago