248 Arrays Chapter 7 1 // Fig. 7.5: (Free php web host)
248 Arrays Chapter 7 1 // Fig. 7.5: StudentPoll.cs 2 // A student poll program. 3 4 using System; 5 using System.Windows.Forms; 6 7 class StudentPoll 8 { 9 // main entry point for application 10 static void Main( string[] args ) 11 { 12 int[] responses = { 1, 2, 6, 4, 8, 5, 9, 7, 8, 10, 1, 13 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, 8, 6, 7, 14 5, 6, 6, 5, 6, 7, 5, 6, 4, 8, 6, 8, 10 }; 15 16 int[] frequency = new int[ 11 ]; 17 string output = “”; 18 19 // increment the frequency for each response 20 for ( int answer = 0; answer < responses.Length; answer++ ) 21 ++frequency[ responses[ answer ] ]; 22 23 output += "RatingtFrequencyn"; 24 25 // output results 26 for ( int rating = 1; rating < frequency.Length; rating++ ) 27 output += rating + "t" + frequency[ rating ] + "n"; 28 29 MessageBox.Show( output, "Student poll program", 30 MessageBoxButtons.OK, MessageBoxIcon.Information ); 31 32 } // end method Main 33 34 } // end class StudentPoll Fig. 7.7 Simple student-poll analysis program. Good Programming Practice 7.1 Strive for program clarity. It is sometimes worthwhile to trade off the most efficient use of memory or processor time for writing clearer programs.
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.