using System; using System.Collections.Generic; using System.Text; namespace LoopsandArrays { class Display { //constructor calls the ShowIT() method public Display() { ShowIT(); } private void ShowIT() { int number = 0; //initialize the variable //used by the out parameter below Console.WriteLine("How many scores do you want to enter"); //test the value entered in the Console readline. //if it does parse as an int pass the value //out to the external variable number if (int.TryParse(Console.ReadLine(), out number) == true) { } else { //if it doesn't exit Console.WriteLine("Not a valid number"); return; } Console.WriteLine("Enter the StudentID"); string st = Console.ReadLine(); //instantiate the TestAverage class and pass //the studentid and the number of scores //to its constructor TestAverage testaverage = new TestAverage(st, number); //in a for loop call the Score array property //of TestAverage and use the loop to assign //the test scores until it reaches the highest index //--one less than number for (int i = 0; i < number; i++) { Console.WriteLine("Enter Score"); //use the counter variable to //increment the index number testaverage.Scores[i]=double.Parse(Console.ReadLine()); } //Call the CalcAverage method of TestAverage Console.WriteLine("the average is {0}", testaverage.CalculateAverage()); //Call the GradePoint method of TestAverage Console.WriteLine("The grade point is {0}", testaverage.GradePoint()); Console.ReadKey(); } } }