I need a help because I've created a program wherein if the user inputs enter an integer number then it will convert the number into Roman Numerals and in Words. But here in my codes, it's only converting it into roman numerals. How can I include literal words of the user input integer into words below the roman numeral. For example: Enter a number: 1 Roman Numeral: I Number in Words: One
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lab_Activity_2
{
internal class Program
{
static void Main(string[] args)
{
string[] units = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" };
string[] decs = { "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" };
string[] cents = { "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" };
string[] mills = { "", "M", "MM", "MMM" };
Console.WriteLine("Enter a number: ");
int n = int.Parse(Console.ReadLine());
if (!(n >= 1 && n <= 3999))
{
Console.WriteLine("Number not valid!");
return;
}
int m = n / 1000;
int mig = n % 1000;
int c = mig / 100;
mig = mig % 100;
int d = mig / 10;
mig = mig % 10;
int u = mig;
Console.WriteLine(mills.ElementAtOrDefault(m) + cents.ElementAtOrDefault(c) + decs.ElementAtOrDefault(d) + units.ElementAtOrDefault(u));
}
}
}
I tried to convert the numbers into roman numerals but I don't know how to code the literal words of an integer and where to put it.