0% found this document useful (0 votes)
30 views3 pages

Usman Effendi 10/7/2016 CIS Programming and Logic Technique Lab No.6

This document contains code for functions to calculate the average score from 5 test scores, determine a letter grade from a score, get a valid numeric score from the user, and check if a score is valid. The main module calls the other functions to get 5 scores from the user, determine the grade for each, calculate the average score, and display the results.

Uploaded by

Usman Effendi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Usman Effendi 10/7/2016 CIS Programming and Logic Technique Lab No.6

This document contains code for functions to calculate the average score from 5 test scores, determine a letter grade from a score, get a valid numeric score from the user, and check if a score is valid. The main module calls the other functions to get 5 scores from the user, determine the grade for each, calculate the average score, and display the results.

Uploaded by

Usman Effendi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1

Usman Effendi
10/7/2016
CIS Programming and logic Technique
Lab No.6
// function to calculate the average score
Function Real calcAverage (Real S1, Real s2, Real s3, Real s4, Real s5)
Declare Real average
Set average = (s1+ s2+ s3 + s4+ s5)/5
Return average
End Function

//function to determine the grade


Function String determineGrade (Real score)
Declare String grade
If score >= 90 Then
Set grade = A
Elif If score >= 80 Then
Set grade = B
Elif If score >= 70 Then
Set grade = C
Elif If score >= 60 Then
Set grade = D
Else
Set grade = F
End if
Return grade
End Function

//function to get input score


Function Real getValid Score()
Declare String score
Display Enter a test score:

2
Input score
While isInvalid(score)
Display ERROR! The score cannot be less than 0 or greater than 100!
Display Enter the correct score:
Input
End While
Return String ToReal(score)
End Function

//function to check for numeric and invalid score


Function Boolean isInvaild(String score)
Declare Boolean status
If not(isReal(score)) or string ToReal(score) < 0 or stringToReal(score)> 100
Then
Set status =True
Else
Set Status = False
End if
Return status
End Function

//main module to control the program


Module main()
Declare Real score1, score2, score3, score4, score5
Declare Real averageScore
Set score1 = getValidScore()
Display 'The grade is , determineGrade(score1)
Set score 2= getValidScore()
Display The grade is , determineGrade(score2)
St score3 = getValidScore()
Display The grade is , determineGrade(score3)

3
Set score4 = getValidScore()
Display The grade is ',determineGrade(score4)
Set score5 = getValidScore()
Display'The grade is ',determineGrade(score5)
Set average= calcAverage(score1, score2, score3, score4, score5)
Display 'The average score is ',averageScore
End Module

You might also like