1. A namespace does not directly contain members such as fields or methods line 73 file roman.cs
2. Expected class, delegate, enum, interface, or struct line 83 file roman.cs
3. Expected class, delegate, enum, interface, or struct line 122 file roman.cs
4. Expected class, delegate, enum, interface, or struct line 127 file roman.cs
5. Expected class, delegate, enum, interface, or struct line 132 file roman.cs
6. Expected class, delegate, enum, interface, or struct line 133 file roman.cs
7. Type or namespace definition, or end-of-file expected line 141 file roman.cs
and now this is my own code... some of the codes are from the internet.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Roman rm = new Roman();
Console.WriteLine("enter roman: ");
string rom = Console.ReadLine();
rm.RomanNumber = rom;
int dc;
int i;
try
{
for ( i = 0; i < 10; i++)
{
switch (rm.RomanNumber[i])
{
case 'M':
case 'm':
dc = 1000;
Console.WriteLine(dc);
break;
case 'D':
case 'd':
dc = 500;
Console.WriteLine(dc);
break;
case 'C':
case 'c':
dc = 100;
Console.WriteLine(dc);
break;
case 'L':
case 'l':
dc = 50;
Console.WriteLine(dc);
break;
case 'X':
case 'x':
dc = 10;
Console.WriteLine(dc);
break;
case 'V':
case 'v':
dc = 5;
Console.WriteLine(dc);
break;
case 'I':
case 'i':
dc = 1;
Console.WriteLine(dc);
break;
default:
break;
//Console.Write("error:");
}
//return dc;
}
if (rom[i] < rom[i])
{
dc = rom[i] - rom[i];
Console.WriteLine("dc");
}
else if(rom[i] >= rom[i])
{
dc=rom[i]+rom[i];
Console.WriteLine("dc");
}
}
catch (IndexOutOfRangeException e) { }
}
}
}
and here is the output
Enter roman:
mmxiv
1000
1000
10
1
5
it means the result is 2016 if they add but the expected output it must be 2014
btw where is the link for all the BB Codes? usually on some forums is located at the bottom but on this forum. I can't find it
Note: please don't close this thread. I'm only using my friend laptop to post my question. I need to reply if ever someone reply to this thread
Question
Gil37
Hi to all members and admins here.... and here I am posting a the same question
I already create a thread but the admin close it....
I have this problem on C# and I can't solve it. Please help....
i use simplezz code: https://www.neowin.net/forum/topic/1228967-c-convert-roman-numerals-to-decimalinteger/?view=findpost&p=596572777
and give me error
here are the error of simplezz code:
1. A namespace does not directly contain members such as fields or methods line 73 file roman.cs
2. Expected class, delegate, enum, interface, or struct line 83 file roman.cs
3. Expected class, delegate, enum, interface, or struct line 122 file roman.cs
4. Expected class, delegate, enum, interface, or struct line 127 file roman.cs
5. Expected class, delegate, enum, interface, or struct line 132 file roman.cs
6. Expected class, delegate, enum, interface, or struct line 133 file roman.cs
7. Type or namespace definition, or end-of-file expected line 141 file roman.cs
and now this is my own code... some of the codes are from the internet.
and here is the output
Enter roman:
mmxiv
1000
1000
10
1
5
it means the result is 2016 if they add but the expected output it must be 2014
btw where is the link for all the BB Codes? usually on some forums is located at the bottom but on this forum. I can't find it
Note: please don't close this thread. I'm only using my friend laptop to post my question. I need to reply if ever someone reply to this thread
Link to comment
Share on other sites
9 answers to this question
Recommended Posts