﻿/*
 * Problem 12. Index of letters
 * Write a program that creates an array containing all letters from the alphabet (A-Z).
 * Read a word from the console and print the index of each of its letters in the array.
 */

using System;

class P12_IndexOfLetters
{
    static void Main()
    {
        // populating array
        string[] letters = new string[27];

        for (int i = 1; i <= letters.GetUpperBound(0); i++)
        {
            letters[i] = Convert.ToString((char)(64 + i));
        }

        // input
        Console.WriteLine("This program will use the index of the letter in the array\nto give you the position of the letter in the english alphabet.");
        Console.Write("Type a string please: ");
        string input = Console.ReadLine();
        Console.WriteLine();

        // iteraton trough the string
        for (int i = 0; i < input.Length; i++)
        {
            string currentLetter = input.Substring(i, 1).ToUpper();
            
            if (!char.IsLetter(Convert.ToChar(currentLetter)))
            {
                continue;
            }

            Console.Write("The letter {0} is at position {1}", input.Substring(i, 1), Array.IndexOf(letters, currentLetter));
            Console.WriteLine(" in the english alphabet.");
            Console.WriteLine();
        }
    }
}