I came up with these two arrays and now i need to search the nameArray by a name inputted by the user and then show the corresponding index value from the scoreArray? Any ideas?
public class InitArraya
{
public static string[] arrayName = new string[5]; // declare array named array
public static int[] arrayScore = new int[5];
public static void PopulateNameArray()
{
// Prompt user for names and assign values to the elements of the array
for (int intCounter = 1; intCounter < arrayName.Length; intCounter++)
{
Console.Write("Enter name {0}: ", intCounter);
arrayName[intCounter] = Console.ReadLine();
}
}
public static void PopulateScoreArray(string[] array)
{
// Prompt user for names and assign values to the elements of the array
for (int intCounter = 0; intCounter < 5; intCounter++)
{
Console.Write("Enter score for {0}: ", arrayName[intCounter]);
arrayScore[intCounter] = Convert.ToInt32(Console.ReadLine());
}
}
public static int FindStudentPosition(string name, string[] array)
{
string target=0;
int result;
target = Console.ReadLine();
Array.FindAll(arrayName, s => s.Equals(target));
return result;
}
public static void Main( string[] args )
{
Console.WriteLine("Enter 5 names:"); // headings
PopulateNameArray();
PopulateScoreArray(arrayName);
Console.ReadLine();
} // end Main
} // end class InitArray