Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone help with this MATLAB problem??? Thank you so much!! Write a function called rom2num that converts Roman numerals to numbers. Recall characters in

Can anyone help with this MATLAB problem??? Thank you so much!!

Write a function called rom2num that converts Roman numerals to numbers. Recall characters in Roman numerals are

numeral

number

I

1

V

5

X

10

L

50

C

100

D

500

M

1000

The input is a valid Roman numeral entered as a string. The output is a number. For example, rom2num(VII) yields 7.

There are many approaches. See section 9.2 of van Loan for an approach. We will discuss section 9.2 in lecture 5. A simpler approach is the following.

Write a function called Converter that takes the strings I,V,X,L,C,D,M and returns the corresponding numbers. Use the switch case construction for the different possibilities.

Set S=0.

Read the characters from left to right

At each step call the function Converter. Add the corresponding value to S.

At each step check the value of the previous character. If it is less, then subtract two times that value from S.

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

=+a. Who has the absolute advantage in coffee? Explain.

Answered: 1 week ago