ornakash

Targil 20

May 15th, 2021
547
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static void Main(string[] args)
  2.         {
  3.             string[] playersName = new string[11];
  4.             int[] playersScore = new int[11];
  5.  
  6.  
  7.             for (int i=0; i<playersName.Length; i++)
  8.             {
  9.                 Console.Write($"({i + 1}) Please enter the player name: ");
  10.                 string playerName = Console.ReadLine();
  11.                 Console.Write($"({i + 1}) Please enter the player score: ");
  12.                 int playerScore = int.Parse(Console.ReadLine());
  13.                 Console.WriteLine("======================================");
  14.                 playersName[i] = playerName;
  15.                 playersScore[i] = playerScore;
  16.  
  17.             }
  18.  
  19.             //1
  20.             int biggestScore = 0;
  21.             for(int i=0; i<playersName.Length; i++)
  22.             {
  23.                 if(playersScore[i]>biggestScore)
  24.                 {
  25.                     biggestScore = playersScore[i];
  26.                 }
  27.             }
  28.             Console.WriteLine($"The biggest score is: {biggestScore}");
  29.  
  30.             //2
  31.             int sumScore = 0;
  32.             for (int i = 0; i < playersName.Length; i++)
  33.             {
  34.                  sumScore += playersScore[i];
  35.             }
  36.             Console.WriteLine($"The sum of all scores is: {sumScore}");
  37.  
  38.             //3
  39.             float average = sumScore / playersScore.Length;
  40.             Console.WriteLine($"The average score is: {average}");
  41.  
  42.             //4
  43.             Random random = new Random();
  44.             int randomIndex = random.Next(0, 11);
  45.             Console.WriteLine($"Random: {playersName[randomIndex]} with score of {playersScore[randomIndex]}");
  46.  
  47.             //5
  48.             Console.WriteLine($"The difference is: {5-average}");
  49.  
  50.             //6
  51.             int smallestScore = biggestScore;
  52.             int playerIndex = -1;
  53.             for (int i = 0; i < playersName.Length; i++)
  54.             {
  55.                 if(playersScore[i]< smallestScore)
  56.                 {
  57.                     smallestScore = playersScore[i];
  58.                     playerIndex = i;
  59.                 }
  60.             }
  61.             Console.WriteLine($"The smallest score is: {smallestScore} of player {playersName[playerIndex]}");
  62.  
  63.             Console.Read();
  64.  
  65.         }
RAW Paste Data