Scenario:
Write a program that will determine the average mark of each student. The average is dependent on the subjects which the student has completed. The minimum amount of subjects is eight, and the maximum amount of subjects is 12. When the program starts, the administrator will indicate how many students there are in the group.
a. Write the algorithm for this program.
My homework rough work:
a.
~Algorithm for the scenario above
Display, 'Please enter average mark of each student'
enter mark
Display, 'Please enter number of subjects student completed'
enter number
Display, 'Please enter student minimum number of subjects'
enter minimum
Display, 'Please enter student maximum number of subjects'
enter maximum
Display, 'Please enter amount of students in a group'
enter amount
if subjects =>< 8, then
aveMark = aveTotal
else
if subjects => 12, then
aveMark = aveTotal
else
if numStudents = students, then
aveGroupMark = aveGroupTotal
else
if studentMark = amount, then
studentMark = total
Endif
Endif
Endif
Endif
End
I am not good in programming at all but i would love however to know how it should be. I really tried. Hope in the future I'll excell. Thank you!
2 answers
minSubjects = 8
maxSubjects = 12
Display "Enter the number of students: "
enter students
for s = 1 to students
Display "Enter the scores for student #",s
enter scores
n = length(scores)
if (n<minSubjects) or (n>maxSubjects) then
Display "The number of scores must be between ",minSubjects," and ",maxSubjects
else
avg = 0
for i=1 to n
avg += scores[i]
next i
Display "The average score for Student #",s," is ",avg
endif
next s
avg /= n
Display "The average score for Student #",s," is ",avg