1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
// main module
int main()
// Local variables
int average
// Get scores
//Call getScores(average)
// Show average grade
//Call showAverage(average)
End Module
// The getScores module gets object mass
Module getScores(Int Ref average)
In entry, inputAmount, s1, s2, s3, s4, s5, average
count<< "Enter 5 test scores: "
For entry = 1 to 5
count<< "Enter number ", entry, " score: "
cin>> inputAmount
Select entry
Case 1:
Set s1 = inputAmount
Case 2:
Set s2 = inputAmount
Case 3:
Set s3 = inputAmount
Case 4:
Set s4 = inputAmount
Case 5:
Set s5 = inputAmount
End function
// show letter grade
count<< "The grade is ", determineGrade(inputAmount)
End For
// calculate average grade
Set average = calcAverage(s1, s2, s3, s4, s5)
End Module
// The showAverage module shows kinetic energy
Module showAverage(Int average)
count<< "Average score: ", average
count<< "Letter grade: ",determineGrade(average)
End Module
// The calcAverage function returns average of 5 grades
Function Integer calcAverage(Integer s1, s2, s3, s4, s5)
Declare Integer answer
Set answer = (s1 + s2 + s3 + s4 + s5) / 5
Return answer
End Function
// The determineGrade function returns letter grade
Function String determineGrade(Int score)
If score >= 90 then
Return "A"
Else
If Score >= 80 Then
Return "B"
Else
If score >= 70 Then
Return "C"
Else
If score >= 60 Then
Return "D"
Else
Return "F"
End If
End If
End If
End If
End Function
system("PAUSE");
return EXIT_SUCCESS;
}
|