You are on page 1of 3

Imagine you have a list of 25 students, where each student is represented by a

dictionary. This dictionary contains the student's name, a list of their marks for
each subject, and other relevant information (e.g., total mark, average mark,
grade). All students take the same number of subjects which is 4 subjects.

Write a program that:

1. Calculates the combined total mark for each student by summing their
marks in all subjects.
2. Calculates the average mark for each student by dividing the total mark
by the number of subjects.
3. Assigns a grade to each student based on average marks (e.g.,A* = 88-
100, A= 77-87, B= 66-76, C=55-65, D= 44-54, U=<44, etc.) and stores it
in the student's dictionary.
4. Keeps track of the number of students who received each grade
(distinctions, merits, passes, fails).
5. Outputs the following for each student:
○ Name
○ Combined total mark
○ Average mark
○ Grade
6. Outputs the final class statistics for distinctions, merits, passes, and fails.

ANSWER ON NEXT PAGE OPEN WITH CARE

DECLARE name: ARRAY [1:25] OF STRING


DECLARE totalm: ARRAY [1:25] OF INTEGER
DECLARE avgm: ARRAY [1:25] OF FLOAT
DECLARE grade: ARRAY [1:25] OF STRING
DECLARE s1m: ARRAY [1:25] OF INTEGER
DECLARE s2m: ARRAY [1:25] OF INTEGER
DECLARE s3m: ARRAY [1:25] OF INTEGER
DECLARE s4m: ARRAY [1:25] OF INTEGER
DECLARE countA* AS INTEGER
DECLARE countpass AS INTEGER
DECLARE countfail AS INTEGER

countA*<-0
countpass<-0
countfail<-0
FOR I <- 1 TO 25
OUTPUT “Enter Name:”
INPUT name[I]
OUTPUT “Enter Marks for the first subject”
INPUT s1m[I]
REPEAT
IF s1m[I]>100 OR s1m[I]<0
OUTPUT “Marks need to be between 0 and 100”
OUTPUT “Enter Marks for the first subject”
INPUT s1m[I]
ENDIF
UNTIL s1m<101 AND s1m>-1
OUTPUT “Enter Marks for the second subject”
INPUT s2m[I]
REPEAT
IF s2m[I]>100 OR s2m[I]<0
OUTPUT “Marks need to be between 0 and 100”
OUTPUT “Enter Marks for the second subject”
INPUT s2m[I]
ENDIF
UNTIL s2m<101 AND s2m>-1
OUTPUT “Enter Marks for the third subject”
INPUT s3m[I]
REPEAT
IF s3m[I]>100 OR s3m[I]<0
OUTPUT “Marks need to be between 0 and 100”
OUTPUT “Enter Marks for the third subject”
INPUT s3m[I]
ENDIF
UNTIL s3m<101 AND s3m>-1
OUTPUT “Enter Marks for the fourth subject”
INPUT s4m[I]
REPEAT
IF s4m[I]>100 OR s4m[I]<0
OUTPUT “Marks need to be between 0 and 100”
OUTPUT “Enter Marks for the fourth subject”
INPUT s4m[I]
ENDIF
UNTIL s4m<101 AND s4m>-1
totalm[I]= s1m[I]+s2m[I]+s3m[I]+s4m[I]
avgm[I]=totalm[I]/4
IF avgm[I]<101 AND avgm[I]>87 THEN
grade[I]<- “A*”
ELSEIF avgm[I]<88 AND avgm[I]>76 THEN
grade[I]<- “A”
ELSEIF avgm[I]<77 AND avgm[I]>65 THEN
grade[I]<- “B”
ELSEIF avgm[I]<66 AND avgm[I]>54 THEN
grade[I]<-”C”
ELSEIF avgm[I]<55 AND avgm[I]>43 THEN
grade[I]<- “D”
ELSEIF avgm[I]<44 AND avgm[I]>-1
grade[I]<- “U”
ENDIF
NEXT I
FOR I <- 1 TO 25
IF grade[I] = “A*” THEN
countA*=countA*+1
ENDIF
IF grade[I] = “A*” OR grade[I] = “A” OR grade[I] = “B” OR grade[I] = “C” OR grade[I] =
“D” THEN
countpass=countpass+1
ELSE
countfail=countfail+1
NEXT I
FOR I <- 1 TO 25
OUTPUT “Student name”, name[I]
OUTPUT “Total marks”, totalm[I]
OUTPUT “Average marks”, avgm[I]
OUTPUT “Grade”, grade[I]
NEXT I
OUTPUT “Number of students who scored A*:”, countA*
OUTPUT “Number of students who passed:”, countpass
OUTPUT “Number of students who failed:”, countfail

You might also like