Click here to Skip to main content
15,346,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
How to convert Roman numerals to Integer in C#
without any built-in function and step by step

What I have tried:

How to convert Roman numerals to Integer in C#
without any built-in function and step by step
Posted
Updated 29-Dec-21 7:29am
Comments
BillWoodruff 28-Dec-21 2:49am
   
If we do your homework/coding for you, you will learn nothing.

Coming up with the "step-by-step" is your job. That's the point of the exercise. You have to think about the problem and come up with the algorithm that solves it.

Do it on paper, one step at a time, and document precisely what you're doing at each step. If you look at a character to see what it is, you document that as a step.
   
Comments
Patrice T 28-Dec-21 12:53pm
   
+5
   
Quote:
How to convert Roman numerals to Integer in C# without any built-in function and step by step

1) study how roman numerals are built Roman numerals - Wikipedia[^]
2) Get many samples and solve them by hand, you are following rules, they are the basis of your algorithm.
3) Then create your own solution.
   
v2
Comments
BillWoodruff 28-Dec-21 1:27am
   
voted #1: this reply has no content that might help the OP.
Patrice T 28-Dec-21 2:01am
   
Even link to Roman Numerals ?
Difficult to help OP as he clain no problem and just want a full blowup solution with explanation.
BillWoodruff 28-Dec-21 2:46am
   
"Difficult to help OP as he clain no problem and just want a full blowup solution with explanation."

So, a statement with no content deserves a solution with no content ?

You are a tourist, lost in a big city: you ask a local for directions to the bank; they reply: " 'bank' is found in the 'B' section of the dictionary." :)
ahmedbelal 28-Dec-21 3:34am
   
https://www.dictionary.com/e/roman-numerals/
ahmedbelal 28-Dec-21 3:36am
   
Write a C# programming to convert a given roman number to an integer.

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
ahmedbelal 28-Dec-21 2:47am
   
https://www.dictionary.com/e/roman-numerals/
ahmedbelal 28-Dec-21 3:36am
   
Write a C# programming to convert a given roman number to an integer.

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
0x01AA 28-Dec-21 10:49am
   
Even if my vote really doesn't count against the 1, I'll give you a 5.
Patrice T 28-Dec-21 12:44pm
   
Thank you.
CHill60 30-Dec-21 4:53am
   
0x01AA said "Even if my vote really doesn't count against the 1" ... Mine will though, so 5'd. Enough content to push a write-my-homework-for-me-seeker in the right direction whilst still making them do the work. You see, I actually bothered to read the content on the link.
Patrice T 30-Dec-21 8:17am
   
Thank you.
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
   
Add the following to your dictionary; then proceed from the left; matching the first 2 chars; if not a match, the first 1 char. Remove the 2 or 1 leading matched chars; repeat the lookup. Add the dictionaries values to get the final result.

CM 900, CD 400, XC 90, XL 40, IX 9, IV 4

MCMLXXXIV = M CM L X X X IV = 1000 + 900 + 50 + 10 + 10 + 10 + 4 = 1984
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900