This is a practice problem for my test, I watched a bunch of videos and tutorials about functions and I still don't understand how to do this. Can anyone help program this and explain to me how you did it or get me started atleast? I just dont understand it
Create a function letterToInt with the following interface:
int letterToInt( char letter )
This function should accept a character value as a parameter. This variable represents one symbol in a roman numeral. Your function should return the integer equivalent (e.g., if you pass the function an 'X', it would return the number 10). The function should return -1 if the letter passed to it is not a valid letter in a roman numeral.
Additional Requirements:
• Use a switch statement in your function.
• Your function should contain only one return statement.
Write a main() function to test your function.
The valid roman numerals and their meanings are:
I - 1
V - 5
X - 10
L - 50
C - 100
M - 1000
NOTE: This function does not need to handle a complete roman number such XIV; it only handles one digit.
Sine the function handles only 1 digit it's borderline trivial to implement.
Hint: You need 6 if's in order to check each letter, and use return in every if in order to return the correct number. At the end of the function (and outside any if) you just need to return -1.
Alternatively: Use a switch statement, where you'll have 6 cases and return -1 in default case.