/* Specification: lsd Lab 5 Exercise A This program takes input from the user taking player names (up to 100) and player scores (up to 100). When the user enters Q to quit the program a summary is displayed with all the player names, player scores, the average score, then a list of players who scored below the average. */
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace LAB5
{
class Program { static void Main(string[] args) { // initializing variables string[] playerNamesArray = new string[100]; int[] playerScoresArray = new int[100]; int numberOfplayers = 0; double averageScore;
// calls the various methods that supply the different functions for the program InputData(playerNamesArray, playerScoresArray, ref numberOfplayers); DisplayPlayerData(playerNamesArray, playerScoresArray, numberOfplayers); averageScore = CalculateAverageScore(playerScoresArray, numberOfplayers); DisplayBelowAverage(playerNamesArray, playerScoresArray, numberOfplayers, averageScore); }
// This method takes the input from the user. It enters the player's names and scores into different arrays. // Once the user enters a Q it will break from this method and return to Main(). static void InputData(string[] nameArray, int[] scoreArray, ref int numberOfArraySlots) { while (numberOfArraySlots < nameArray.Length) { Console.Write("Enter Player Name (Q to quit): "); nameArray[numberOfArraySlots] = Console.ReadLine();
if (nameArray[numberOfArraySlots].Substring(0).ToUpper() == "Q") { break; }
Console.Write("Enter score for {0} :