Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Roman Numerals Create a function that takes in a Roman numeral as a string and converts it to an integer, returning the result. The

C++

Roman Numerals

Create a function that takes in a Roman numeral as a string and converts it to an integer, returning the result. The function should work for all Roman numerals representing positive integers less than 4000

readRomanNumbers("VII") 7 readRomanNumbers("DCLXXIX") 679 readRomanNumbers("MMMCMV") 3905Examples

Notes

  • All letters will be in uppercase.

  • Assume all inputs will be well-formed Roman numerals.

  • While you could probably solve this by separately checking for each of these

    sequences inside the string, there is a smarter way. Think about the numerical value each individual letter has, and how the letter immediately following it can affect that letter's numerical value.

    int readRomanNumbers(std::string num) { }

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

Students also viewed these Databases questions