0 Replies - 712 Views - Last Post: 21 February 2011 - 10:33 AM Rate Topic: -----

#1 Guest_Afterme*


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
	Display “Please enter your score for Test 1.”
	Input test1
	Set score1 = determineGrade (test1)
	Display “Please enter your score for Test 2.”
	Input test2
	Set score2 = determineGrade (test2)
	Display “Please enter your score for Test 3.”
	Input test3
	Set score3 = determineGrade (test3)
	Display “Please enter your score for Test 4.”
	Input test4
	Set score4 = determineGrade (test4)
	Display “Please enter your score for Test 5.”
	Input test5
	Set score5 = determineGrade (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



FUNCTION determineGrade(SCORE)

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