Page 1 of 1

Reputation:

# Stuck with a function pseudocode. Need some pointers.

Posted 21 February 2011 - 10:33 AM

Hi guys I've read on the internet this was the place to be if I wanted help on programming so I decided to give it a chance. I'm trying really hard in my class but I'm still having trouble understanding programming.

The code I'm using is a pseudo-code from a book called "Programming Logic and Design 2nd Edition".

I'm having trouble with functions right now and I was wondering if you guys could double check my work. I believe I may have errors in this pseudo-code. Also how would I set the code so I can get a letter grade for the average? Thanks and hope to hear from you guys soon.

The problem is:
Write a program that asks the user to enter five test scores. the program should display a letter grade for each score and average test score. design the following functions in the program:

*calcAverage-this function should accept five test scores as arguments and return the average of the scores.

*determineGrade-this function should accept a test score as an argument and return a letter grade for teh score (as a String), based on the following grading scale:
Score-90-100=A, 80-89=B,70-79=C, 60-69=D, BELOW 60=F.

My pseudo-code:
```Module Main( )
Declare Integer test1, test2, test3, test4, test5
Declare Integer score1, score2, score3, score4, score5
Declare Integer average
Input test1
Input test2
Input test3
Input test4
Input test5
Set average = calcAverage (test1,test2,test3,test4,test5)
End Module

FUNCTION CalcScore( SCORE1,SCORE2,SCORE3,SCORE4,SCORE5)
DECLARE TOTAL,AVERAGE
SET TOTAL=SCORE1+SCORE2+SCORE3+SCORE4+SCORE5

SET AVERAGE=TOTAL/5
RETURN AVERAGE
END FUNCTION

IF SCORE>=90 THEN
RETURN "A"
END IF
IF SCORE >=80 AND SCORE<90
RETURN "B"
END IF
IF SCORE >=70 AND SCORE<80
RETURN "C"
END IF
IF SCORE >=60 AND SCORE<70
RETURN "D"
END IF
IF SCORE<60
RETURN "E"
END IF
END FUNCTION

```

Is This A Good Question/Topic? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }