Subject: C# .NET Write a program that takes a decimal value between 1 and 10 and
ID: 3866637 • Letter: S
Question
Subject: C# .NET
Write a program that takes a decimal value between 1 and 10 and displays its equivalent Roman numeral value. Display an error message if the value entered is outside of the acceptable range. Write a two class solution. The second class should allow the user to input a test value.
This is what I have so far... I might've over complicated the if-else statement with the Switch selection statements. Also, I'm not sure how to call the romanNumeral class from the Program class.
Unfinished Code with errors:
namespace RomanNumerals
{
//Class to convert decimals to roman numerals
class romanNumeralConvert
{
public static void romanNumeral()
{
decimal number = 0;
if (number >= 1 && number <= 10)
{
switch (number)
{
case 1:
number = "I";
break;
case 2:
number = "II";
break;
case 3:
number = "III";
break;
case 4:
number = "IV";
break;
case 5:
number = "V";
break;
case 6:
number = "VI";
break;
case 7:
number = "VII";
break;
case 8:
number = "VIII";
break;
case 9:
number = "IX";
break;
default:
number = "X";
break;
}
}
else
{
number = "The Number entered must be between 1 and 10";
}
}
}
//Test class
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter a decimal value:"); // Prompt
decimal number = Convert.ToInt32(Console.ReadLine());
string numString = RomanNumerals.romanNumeralConvert.romanNumeral(number);
if (romanNumeralConvert.TryParse(numString, out number))
{
Console.WriteLine("The Roman Numeral is: " + number);
}
Console.ReadKey();
}
}
}