Cis170 Ilab 5

Only available on StudyMode
  • Topic: Personal name, Family name
  • Pages : 4 (363 words )
  • Download(s) : 87
  • Published : March 24, 2013
Open Document
Text Preview
Week 5 iLab

Part A:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lab5A
{
class Program
{
static void Main(string[] args)
{
string[] playerName = new string[100];
int[] playerScore = new int[100];
int c = 0;
c=InputData(ref playerName, ref playerScore);

double avg= CalculateAverageScore(ref playerScore,c);
Console.WriteLine("Name Score");
DisplayPlayerData(ref playerName, ref playerScore, c); Console.WriteLine();
Console.WriteLine("Average Score: " + avg + "\n"); Console.WriteLine("Player's Who Scored Below Average"); Console.WriteLine("Name Score");
DisplayBelowAverage(avg, ref playerName, ref playerScore,c); }
static int InputData(ref string[] player, ref int[] score) {
int addName = 0,counter=0;

do
{
Console.Write("Enter Player's Name (Q to quit): "); player[counter] = Console.ReadLine();

if (player[counter] == "q" || player[counter] == "Q") {
addName = 1;
}
else
{
Console.Write("Enter score for {0}: ", player[counter]); score[counter] = Convert.ToInt32(Console.ReadLine()); counter++;
}
}
while (addName != 1);
return counter;

}

static void DisplayPlayerData(ref string[] playerName, ref int[] playerScore,int counter) {
for (int i = 0; i < counter; i++)
{
Console.WriteLine("{0}\t\t{1}", playerName[i], playerScore[i]); }

}

static double...
tracking img