You always take the first element from the array, hence the selected area code will actually always be 262, whatever you input.
Use
Array.IndexOf
to find the index of the entered area code and then use that index to get the rates per minute. If the user inputted an area code that's not in the list, IndexOf will return
-1
.
int index = Array.IndexOf(areaCodes, areaCode);
if (index == -1)
{
Console.WriteLine("Invalid area code.");
return;
}
cost = ratesPerMinute[index];