118 Control Structures: Part 1 (Kids web site) Chapter 4 Initialize

118 Control Structures: Part 1 Chapter 4 Initialize passes to zero Initialize failures to zero Initialize student to one While student counter is less than or equal to ten Input the next exam result If the student passed Add one to passes Else Add one to failures Add one to student counter Print the number of passes Print the number of failures If more than eight students passed Print Raise tuition Fig. 4.10 Pseudocode for examination-results problem. 1 // Fig. 4.11: Analysis.cs 2 // Analysis of Examination Results. 3 4 using System; 5 6 class Analysis 7 { 8 static void Main( string[] args ) 9 { 10 int passes = 0, // number of passes 11 failures = 0, // number of failures 12 student = 1, // student counter 13 result; // one exam result 14 15 // process 10 students; counter-controlled loop 16 while ( student <= 10 ) 17 { 18 Console.Write( "Enter result (1=pass, 2=fail): " ); 19 result = Int32.Parse( Console.ReadLine() ); 20 21 if( result == 1 ) 22 passes = passes + 1; 23 24 else 25 failures = failures + 1; Fig. 4.11 C# program for examination-results problem. (Part 1 of 2.)
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision virtual web hosting services

Leave a Reply