I've got an Array of 11 numbers, and an array of 11 names. I've also got the Average and the top 3 numbers. The numbers and names are user input'd separately which then go into two separate Arrays.
For example lets say I have:
playerName[0] = player1.Text;
playerName[1] = player2.Text;
playerName[2] = player3.Text;
playerName[3] = player4.Text;
playerName[4] = player5.Text;
playerName[5] = player6.Text;
playerScore[0] = int.Parse(score1.Text);
playerScore[1] = int.Parse(score2.Text);
playerScore[2] = int.Parse(score3.Text);
playerScore[3] = int.Parse(score4.Text);
playerScore[4] = int.Parse(score5.Text);
playerScore[5] = int.Parse(score6.Text);
int highestScore = playerScore.Max();
double averageScore = playerScore.Average();
int largest = int.MinValue;
int second = int.MinValue;
int third = int.MinValue;
foreach (int i in playerScore)
{
if (i > largest)
{
third = second;
second = largest;
largest = i;
}
else if (i > second && i != largest)
second = i;
else if (i > third && i != second)
third = i;
}
Is there any easy way to list out something like this?
textbox.Text = highest score is: " + highestScore + " by " -INSERT RELEVENT playerName HERE-
I Can think of some ways to do but chances are it would turn into a giant clump of if's and switches
Thanks