M
mtran80
Guest
I am writing a program to determine statistic for a video game tournament. The user input names and scores of all tournament players. The program will calculate the average score and display the players who scored below average.
The program will implement these functions:
Main()declares variables for the number of players and average score, and two arrays of size 100: one to store players names, and the other to store their respective scores. Calls the following functions in sequence,
Input data():get players names and scores from the user and stores them into the two arrays for an unknown number of players up to 100
Display data() displays each players name and score
Calculate Ave. Score() calculate the average score and returns it by value
Display Below Average() display the names and scores of players who scored below average.
Below is what I have so far, but I am stuck at the Display Input(). I dont know how to write the Display Input data for it to call into the main method()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace iLab05A
{
class Program
{
static void Main(string[] args)
{
double [] scoresArray = new double[100];
string [] playersArray = new string[100];
char reloop = Y;
int count = 0;
do
{
double averageScore = 0;
double belowAverage = 0;
int numbers = 0;
InputData(ref scoresArray, ref playersArray, count);
DisplayPlayerData(ref scoresArray, ref playersArray, count);
CalculateAverageScore(ref scoresArray, ref playersArray, count);
Console.ReadLine();
DisplayBelowAverage(ref scoresArray, ref playersArray, count);
reloop = Convert.ToChar(Console.ReadLine());
reloop = char.ToUpper(reloop);
} while (reloop != Y);
}
static void InputData(ref double[] scoresArray, ref string[] playersArray, int count)
{
while (playersArray.Length <= 100)
{
Console.Write("Please enter the players name: " + "((Q to Quit)) ");
playersArray[count] = Console.ReadLine();
if (playersArray[count] == "Q" || playersArray[count] == "q")
{
break;
}
Console.Write("Please enter " + playersArray[count] + " scores: ");
scoresArray[count] = Convert.ToDouble(Console.ReadLine());
count++;
}
}
static void DisplayPlayerData(ref double [] scoresArray, ref string [] playersArray, int count)
{
for (int i = 0; i < playersArray.Length; i++)
{
Console.ReadLine();
}
}
static void CalculateAverageScore(ref double[] scoresArray, ref string[] playersArray, int count)
{
int total = 0;
double average = 0;
{
foreach (int s in scoresArray)
total += s;
average = total / scoresArray.Length;
Console.Write("Average score is : ", average);
Console.ReadLine();
}
}
static void DisplayBelowAverage(ref double [] scoresArray, ref string [] playersArray, int count)
{
Console.Write("Players who score below average: ");
Console.ReadLine();
}
}
}
***I am stuck at the Display Players Data() I start using the For Loop, but I dont know how to loop it so it can read the information inside the Input Data() to display the Names along with the Scores when I run the program
Continue reading...
The program will implement these functions:
Main()declares variables for the number of players and average score, and two arrays of size 100: one to store players names, and the other to store their respective scores. Calls the following functions in sequence,
Input data():get players names and scores from the user and stores them into the two arrays for an unknown number of players up to 100
Display data() displays each players name and score
Calculate Ave. Score() calculate the average score and returns it by value
Display Below Average() display the names and scores of players who scored below average.
Below is what I have so far, but I am stuck at the Display Input(). I dont know how to write the Display Input data for it to call into the main method()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace iLab05A
{
class Program
{
static void Main(string[] args)
{
double [] scoresArray = new double[100];
string [] playersArray = new string[100];
char reloop = Y;
int count = 0;
do
{
double averageScore = 0;
double belowAverage = 0;
int numbers = 0;
InputData(ref scoresArray, ref playersArray, count);
DisplayPlayerData(ref scoresArray, ref playersArray, count);
CalculateAverageScore(ref scoresArray, ref playersArray, count);
Console.ReadLine();
DisplayBelowAverage(ref scoresArray, ref playersArray, count);
reloop = Convert.ToChar(Console.ReadLine());
reloop = char.ToUpper(reloop);
} while (reloop != Y);
}
static void InputData(ref double[] scoresArray, ref string[] playersArray, int count)
{
while (playersArray.Length <= 100)
{
Console.Write("Please enter the players name: " + "((Q to Quit)) ");
playersArray[count] = Console.ReadLine();
if (playersArray[count] == "Q" || playersArray[count] == "q")
{
break;
}
Console.Write("Please enter " + playersArray[count] + " scores: ");
scoresArray[count] = Convert.ToDouble(Console.ReadLine());
count++;
}
}
static void DisplayPlayerData(ref double [] scoresArray, ref string [] playersArray, int count)
{
for (int i = 0; i < playersArray.Length; i++)
{
Console.ReadLine();
}
}
static void CalculateAverageScore(ref double[] scoresArray, ref string[] playersArray, int count)
{
int total = 0;
double average = 0;
{
foreach (int s in scoresArray)
total += s;
average = total / scoresArray.Length;
Console.Write("Average score is : ", average);
Console.ReadLine();
}
}
static void DisplayBelowAverage(ref double [] scoresArray, ref string [] playersArray, int count)
{
Console.Write("Players who score below average: ");
Console.ReadLine();
}
}
}
***I am stuck at the Display Players Data() I start using the For Loop, but I dont know how to loop it so it can read the information inside the Input Data() to display the Names along with the Scores when I run the program
Continue reading...