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

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 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