An algorithm is a representation of a solution to a problem. For computer programs, a procedure, explicitly stating the steps leading to the solution, must be transmitted to the computer. This concept of problem solution and communication makes the study of algorithms important to computer science.
For a computer to perform a desired task, a method for carrying out some sequence of events, resulting in accomplishing the task, must somehow be described to the computer. An algorithm is a set or list of instructions for carrying out some process step by step. A recipe in a cookbook is an excellent example of an algorithm. The recipe includes the requirements for the cooking or ingredients and the method of cooking them until you end up with a nice cooked dish.
Pseudocode (or Structured English) is used to outline program logic in a “readable,” English-like manner, independent of any specific programming language. This simplifies program development by separating it into two main parts, logic design and coding. Once the logic is developed, coding becomes the translation of the pseudocode into the required programming language.
Pseudocode can be broken down into six components.
- Assignment: variables are determined and given names
- Input: acquire values for the defined variables
- Output/Display: actions to be done with results of steps within the code
- Selection/Decision: determine which values or variables are to be used during each step of the algorithm
- Iteration (Repetition): if the algorithm is designed to do the same steps multiple times, the iteration steps describe that process
- Processing: the actual calculations or procedures of what is going on between the input and output.
After reading Section 1.7 in your textbook, read the scenario below and write the algorithm and pseudocode to solve the problem.
A friend has asked you to design a simple gradebook program. He would like to create some calculations that can be used for any test given to students. This program should generate percentage scores for each student (given the number of correct answers and the total number of questions on the test).
He would also like the program to calculate the class average of the percentage scores and identify the minimum and maximum scores for the class.
Write the pseudocode for this electronic gradebook. For those who are ready for a little more advanced concepts, have your pseudocode determine the letter grade for each student (90+ = A, 80+ = B, 70+ = C, 64+ = D, Lower than 64 = F).
Instructor Feedback: Students can find their feedback in the Grade Center.