Question: Exercise 4: Calculating a Course Grade reference: Worked Example 5.2 B+,B,BC+,C,CD+,D,D or F) for each of them. The course grade is determined by dropping the

 Exercise 4: Calculating a Course Grade reference: Worked Example 5.2 B+,B,BC+,C,CD+,D,D

Exercise 4: Calculating a Course Grade reference: Worked Example 5.2 B+,B,BC+,C,CD+,D,D or F) for each of them. The course grade is determined by dropping the lowest grade and averaging the three remaining grades. To average grades, first convert them to numher grades, using the usual scheme A+=43.A=40.A=37B=33D=07F=0 Then compute their average and convert it back to the closest letter grade. For example, an average of 3.51 would be an A. Your task is to read inputs of the form: letterGradel letterGrade2 letterGrade3 letterGrade4 For example, AB+CA s For each input line, your output should be letterGrade where the letter grade is the grade eamed in the course, as just described. For example, A The end of inputs will be indicated by a letterGradel input of Q. Step 1: Carry out stepwise refinement. We will use the process of stepwise refinement. To process the inputs, we can process each line individually. Therefore, we declare a task Process line. To process a line, we read the first grade and bail out if it is a Q. Otherwise, we read the four grades. Because we need them in their numeric form, we identify a task Convert letter grade to number. We then have tour numbers and need to find the smallest one. I hat is another task, Find smallest of four numbers. To average the remaining ones, we compute the sum of all values, subtract the smallest and divide by three. Let's say that is not worth making into a subtask. Next, we need to convert the result back into a letter grade. That is yet another subtask. Convert number grade to letter. Finally, we print the letter grade. That is again so simple that it requires no subtask

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!