Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Will you check this? It\'s my attempt at this problem. Please post any correctio

ID: 3919143 • Letter: W

Question

Will you check this? It's my attempt at this problem. Please post any corrections or comments. Thanks!

You are given a file that contains the course number and the number of students enrolled in each course.     You need to use a modular design to solve the problem.
1.   Place the course numbers and enrollment in parallel arrays.
2.   Print a listing of all course numbers and enrollments.
3.   Calculate and print the total number of students in all classes.
4.   Calculate and print the average number of students in the classes.
5.   Print the class numbers and enrollments for classes with less than 10 students.
6.   Print the class number and enrollment for the class with the highest enrollment.

Module main ()
   Declare Constant Integer SIZE
   Declare Integer courseNumbers[SIZE]
   Declare Integer enrollment[SIZE]
   Declare Integer totalStudents

   Call showClassEnrollment (Integer courseNumber[Size], Integer enrollment[SIZE], SIZE)
   Call calcTotal (Integer courseNumber[Size], Integer enrollment[SIZE], SIZE)
   Call calcAverage (Integer totalStudents)
   Call belowTen (Integer courseNumber[Size], Integer enrollment[SIZE], SIZE)
   Call getHighest (Integer courseNumber[Size], Integer enrollment[SIZE], SIZE)

Module showClassEnrollment (Integer courseNumber[Size], Integer enrollment[SIZE], SIZE)
   Declare Integer index
   For index = 0 To SIZE -1
   Display “The course”, courseNumber[index], “has”, numberStudents[index], “students.”
   End For
End Module

Function Integer calcTotal (Integer courseNumber[Size], Integer enrollment[SIZE], SIZE)
   Declare Integer index
   Declare Integer totalStudents = 0
   For courseNumber[index] = 0 To SIZE -1
       Set totalStudents = totalStudents + numberStudents[index]
   End For
   Display “The total number of students in all classes is:”, total
   Return totalStudents
End Function

Module calcAverage (Integer totalStudents, SIZE)
   Declare Real average
   Set average = totalStudents / SIZE
   Display “The average number of students in all classes is:”, average, “.”
End Module

Module belowTen (Integer courseNumber[Size], Integer enrollment[SIZE], SIZE)
   Declare Integer index
   For index = 0 To SIZE -1
       If enrollment[index] < 10 Then
           Display “The class”, courseNumber[index] “has less than 10 students.”
           Display “It has”, enrollment[index], “students.”
       End If
   End For
End Module
  
Module getHighest (Integer courseNumber[Size], Integer enrollment[SIZE], SIZE)
   Declare Integer index
   Declare Integer highestEnrollement
   Declare Integer highestClass
  
   Set highestEnrollment = enrollment [0]
   For index = 1 To SIZE -1
       If enrollment[index] > highestEnrollment Then
           Set highestEnrollment = enrollment[index]
           Set highestClass = courseNumber[index]
       End If
   End For
Display “The class with the most students is:”, highestClass, “with”, highestEnrollment,
Display “students.”
End Module

Explanation / Answer

According to problem ,it is mentioned that you are provided a file ,in which there is

record of course number and their corresponding enrollments.

Inside main module you have just declared array.
But didn't assign value to array.
which should be assigned by reading value from file word by word.

Besides this every other modules are correct.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote