Michael Reeve
asked on
Scoring System
Experts,
Details
I am trying to create a scoring system where the user will input names and scores of all players. The program will calculate the average score and display all the players who scored below average.
Sample Output
Enter Player Name (Q to quit): Bob
Enter score for Bob: 3245
Enter Player Name (Q to quit): Sue
Enter score for Sue: 1098
Enter Player Name (Q to quit): Q
Name Score
Bob 3245
Sue 1098
Average Score: 3944.75
Players who scored below average
Name Score
Bob 3245
Sue 1098
Variables
My variables are:
InputData( ): Requests the user to input the player names and scores from the user and stores them into the two arrays for an unknown number of players <= 100.
DisplayPlayerData(): Displays each player's name and score.
CalculateAverageScore( ): Calculates the average score and returns it by value.
DisplayBelowAverage( ): Displays the names and scores of players who scored below average.
Comments
Any ideas how to tackle this? New to C#, trying to figure out the code
Thank you very much in advance!
Details
I am trying to create a scoring system where the user will input names and scores of all players. The program will calculate the average score and display all the players who scored below average.
Sample Output
Enter Player Name (Q to quit): Bob
Enter score for Bob: 3245
Enter Player Name (Q to quit): Sue
Enter score for Sue: 1098
Enter Player Name (Q to quit): Q
Name Score
Bob 3245
Sue 1098
Average Score: 3944.75
Players who scored below average
Name Score
Bob 3245
Sue 1098
Variables
My variables are:
InputData( ): Requests the user to input the player names and scores from the user and stores them into the two arrays for an unknown number of players <= 100.
DisplayPlayerData(): Displays each player's name and score.
CalculateAverageScore( ): Calculates the average score and returns it by value.
DisplayBelowAverage( ): Displays the names and scores of players who scored below average.
Comments
Any ideas how to tackle this? New to C#, trying to figure out the code
Thank you very much in advance!
Obviously homework...what have you done so far?
ASKER
Yes, that obvious, huh. I have identified the methods. How can I get the names and scores from the user and place them into an array?
using System;
namespace Wk5_LabA
{
class Program
{
static void Main(string[] args)
{
string[] playerNameAr = new string[100];
double[] scoreAr = new double[100];
int numPlayers = 0;
double averageScore;
static void InputData(playerNameAr, scoreAr, ref numPlayers);
Console.WriteLine("Please enter");
foreach string(string playerNameAr in playerName)
{
Console.WriteLine(playerNameAr)
};
Console.ReadLine();
static void DisplayPlayerData(playerNameAr, scoreAr, numPlayers);
static void averageScore = CalculateAverageScore(scoreAr, numPlayers);
Console.WriteLine("\nAverage Score: {0:F}", averageScore);
static void DisplayBelowAverage(playerNameAr, scoreAr,numPlayers, averageScore);
Console.Read();
}
}
}
The description doesn't specify if the arrays must be passed into the methods. Do you know if you're allowed to use static arrays and variables?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, static arrays and variables are allowed. It is a basic example of the use of arrays, not sure why I am struggling with this basic concept.
See if you can flesh out my last post... =)
ASKER
You provided an excellent shell and a starting point for me to work through. This is what I needed to get moving in the right direction. Really appreciate it.
ASKER
Thank you very much for you help. You provided an excellent starting template. Your comments you provided in each method helped to make it understandable. Thank you!!
Lemme know if you have specific questions implementing it.
ASKER
Thanks I will. I appreciate you directing me down the right path. Thanks