Beispiel #1
0
        // set up for Console App
        static void Main(string[] args)
        {
            Console.WriteLine("Give me a number, so I can make it a Roman Numeral");

            var numberEntered = int.Parse(Console.ReadLine());

            var converter = new RomanConverter();

            var romanNumeralResult = converter.IntToRoman(numberEntered);

            Console.WriteLine(romanNumeralResult);
            Console.ReadLine();

            Console.WriteLine("now give me a number made with roman numerals in all caps");

            var input = Console.ReadLine();

            var integerResult = converter.RomanToInt(input);

            Console.WriteLine(integerResult);
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            int    arabicNum = 0;
            string input     = "";

            Console.WriteLine("Welcome to The Roman Numeral Converter. Enter a number less than 4000, or type 'q' to quit.");

            do
            {
                Console.Write("Enter a number: ");
                input = Console.ReadLine();

                if (!(int.TryParse(input, out arabicNum)) || (arabicNum < 1 || arabicNum > 3999))
                {
                    Console.WriteLine("Invalid entry. Must be between 1-3999.");
                    continue;
                }

                Console.WriteLine(RomanConverter.toRoman(arabicNum));
            } while (input != "q");

            Environment.Exit(0);
        }