Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- string[] playersName = new string[11];
- int[] playersScore = new int[11];
- for (int i=0; i<playersName.Length; i++)
- {
- Console.Write($"({i + 1}) Please enter the player name: ");
- string playerName = Console.ReadLine();
- Console.Write($"({i + 1}) Please enter the player score: ");
- int playerScore = int.Parse(Console.ReadLine());
- Console.WriteLine("======================================");
- playersName[i] = playerName;
- playersScore[i] = playerScore;
- }
- //1
- int biggestScore = 0;
- for(int i=0; i<playersName.Length; i++)
- {
- if(playersScore[i]>biggestScore)
- {
- biggestScore = playersScore[i];
- }
- }
- Console.WriteLine($"The biggest score is: {biggestScore}");
- //2
- int sumScore = 0;
- for (int i = 0; i < playersName.Length; i++)
- {
- sumScore += playersScore[i];
- }
- Console.WriteLine($"The sum of all scores is: {sumScore}");
- //3
- float average = sumScore / playersScore.Length;
- Console.WriteLine($"The average score is: {average}");
- //4
- Random random = new Random();
- int randomIndex = random.Next(0, 11);
- Console.WriteLine($"Random: {playersName[randomIndex]} with score of {playersScore[randomIndex]}");
- //5
- Console.WriteLine($"The difference is: {5-average}");
- //6
- int smallestScore = biggestScore;
- int playerIndex = -1;
- for (int i = 0; i < playersName.Length; i++)
- {
- if(playersScore[i]< smallestScore)
- {
- smallestScore = playersScore[i];
- playerIndex = i;
- }
- }
- Console.WriteLine($"The smallest score is: {smallestScore} of player {playersName[playerIndex]}");
- Console.Read();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement