using System; class Frequencies { /// /// The Frequencies Program Bishop & Horspool 2002 /// ======================= /// Counts the frequencies of marks from 0 to 10. /// Tested by generating random numbers. /// Illustrates simple array handling. /// const int limit = 11; // to keep the table small const int classSize = 250; void Go() { int[] markCount = new int[limit]; int score; Random r = new Random(); // generate 250 marks for (int i=0; i < classSize; i++) { // generates from 0 to limit-1 score = r.Next(limit); markCount[score]++; } Console.WriteLine("Table of mark counts\n"+ "====================\n\n"+ " Mark Occurred"); int students=0; for (int i=0; i < limit; i++) { Console.WriteLine( " {0,4}{1,6}", i, markCount[i]); students += markCount[i]; } Console.WriteLine("Total{0,7}", students); } static void Main() { new Frequencies().Go(); } }