116 Control Structures: Part 1 Chapter 4 Line (Web hosting account)

116 Control Structures: Part 1 Chapter 4 Line 47 displays the value of average. We specify average as the second argument to WriteLine. Method WriteLine will convert this argument to a string and display its value. 4.10 Formulating Algorithms with Top-Down, StepwiseRefinement: Case Study 3 (Nested Control Structures) Let us work through another complete problem. We will again formulate the algorithm using pseudocode and top-down, stepwise refinement; we will write a corresponding C# program. Consider the following problem statement: A college offers a course that prepares students for the state licensing exam for real estate brokers. Last year, several of the students who completed this course took the licensing examination. The college wants to know how well its students did on the exam. You have been asked to write a program to summarize the results. You have been given a list of the 10 students. Next to each name is written a 1 if the student passed the exam and a 2 if the student failed the exam. Your program should analyze the results of the exam as follows: 1. Input each test result (i.e., a 1 or a 2). Display the message Enter result on the screen each time the program requests another test result. 2. Count the number of test results of each type. 3. Display a summary of the test results, indicating the number of students who passed and the number of students who failed the exam. 4. If more than 8 students passed the exam, print the message Raise tuition. After reading the problem statement carefully, we make the following observations about the problem: 1. The program must process test results for 10 students. A counter-controlled loop will be used. 2. Each test result is a number either a 1 or a 2. Each time the program reads a test result, the program must determine if the number is a 1 or a 2. We test for a 1 in our algorithm. If the number is not a 1, we assume that it is a 2. (An exercise at the end of the chapter considers the consequences of this assumption.) 3. Two counters keep track of the exam results one to count the number of students who passed the exam and one to count the number of students who failed. 4. After the program processes all the results, it must decide if more than eight students passed the exam. Let us proceed with top-down, stepwise refinement. We begin with a pseudocode representation of the top: Analyze exam results and decide if tuition should be raised Once again, it is important to emphasize that the top is a complete representation of the program, but several refinements are likely to be needed before the pseudocode can be evolved naturally into a C# program. Our first refinement is
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision personal web hosting services

Leave a Reply