      PROGRAM ACADEM
************************************************************************
* Program to determine academic standing of engineering students       *
* according to two criteria:  cumulative hours and cumulative gpa.     *
* It also counts the total # of students checked, and the # found to   *
* be in good standing and calculates the average current gpa for all   *
* students.  Variables used are:                                       *
*     NUMSTU : total number of students                                *
*     NUMGS  : number in good standing                                 *
*     RESPON : user response to more-data inquiry                      *
*     GPASUM : sum of all current GPAs                                 *
*                                                                      *
* Input:  RESPON; also several items of student information in         *
*         subroutine CALCUL                                            *
* Output: Student report by subroutine REPORT and summary statistics   *
*         by subroutine WRAPUP                                         *
************************************************************************

      INTEGER NUMSTU, NUMGS, RESPON
      REAL GPASUM
      DATA NUMSTU, NUMGS, GPASUM /3*0/

      CALL INFORM

*     Repeat the following until no more data
10    CONTINUE
          CALL PROCES(NUMSTU, NUMGS, GPASUM)
          PRINT *
          PRINT *, 'MORE (0 = NO, 1 = YES)?'
          READ *, RESPON
      IF (RESPON .NE. 0) GO TO 10

      CALL WRAPUP(NUMSTU, NUMGS, GPASUM)
      END 


** INFORM *************************************************************
      SUBROUTINE INFORM

      PRINT *, '*********** INFORM CALLED ***********'
      END


** PROCES **************************************************************
* Accepts student information, determines academic standing, and       *
* maintains counts of # processed and # in good standing, and a sum    *
* of current GPAs.  Variables used are:                                *
*     NUMSTU : total number of students                                *
*     NUMGS  : number in good standing                                 *
*     GPASUM : sum of all current GPAs                                 *
*     SNUMB  : student's number                                        *
*     CLASS  : student's class                                         *
*     CUMHRS : student's cumulative hours                              *
*     CUMGPA : student's cumulative GPA                                *
*     CURGPA : student's current GPA                                   *
*     GOODST : indicates whether student is in good standing           *
* Accepts:  NUMSTU, NUMGS, and GPASUM                                  *
* Returns:  Updated values of NUMSTU, NUMGS, and GPASUM                *
************************************************************************

      SUBROUTINE PROCES(NUMSTU, NUMGS, GPASUM)

      INTEGER NUMSTU, NUMGS, SNUMB, CLASS
      REAL GPASUM, CUMHRS, CUMGPA, CURGPA
      LOGICAL GOODST

      CALL CALCUL(SNUMB, CLASS, NUMSTU, CUMHRS, CUMGPA, CURGPA, 
     +            GPASUM)
      CALL CHECK
      CALL REPORT(SNUMB, CLASS, CUMHRS, CURGPA, CUMGPA)
      END


** WRAPUP *************************************************************
      SUBROUTINE WRAPUP(NUMSTU, NUMGS, GPASUM)

      PRINT *, '*********** WRAPUP CALLED ***********'
      END


** CALCUL **************************************************************
* Subroutine to read a student's number (SNUMB), CLASS, cumulative     *
* hours (CUMHRS), and cumulative gpa (CUMGPA); then read HOURS and     *
* GRADE for courses taken during the current year, and calculate       *
* current GPA (CURGPA), update cumulative hours cumulative GPA, and    *
* count (NUMSTU) of students processed.  HOURS = 0 and GRADE = 0 are   *
* used to signal the end of data for a student.  Other local variables *
* used are:                                                            *
*     NEWHRS : total hours earned during current year                  *
*     NEWPTS : honor points earned in current year                     *
*     OLDPTS : honor points earned in past years                       *
* Accepts:  NUMSTU and GPASUM.                                         *
* Input:    SNUMB, CLASS, CUMHRS, CUMGPA; also HOURS and GRADE for     *
*           each of several courses                                    *
* Returns:  SNUMB, CLASS, CUMHRS, CUMGPA, CURGPA and updated values of *
*           NUMSTU and GPASUM                                          *
************************************************************************

      SUBROUTINE CALCUL(SNUMB, CLASS, NUMSTU, CUMHRS, CUMGPA, 
     +                  CURGPA, GPASUM)

      INTEGER SNUMB, NUMSTU, CLASS
      REAL CUMHRS, CUMGPA, CURGPA, GPASUM, HOURS, GRADE, NEWHRS, 
     +     NEWPTS, OLDPTS


      PRINT *,'ENTER STUDENT NUMBER, CLASS, CUM. HOURS, CUM. GPA:'
      READ *, SNUMB, CLASS, CUMHRS, CUMGPA
      OLDPTS = CUMHRS * CUMGPA
      NEWHRS = 0.0
      NEWPTS = 0.0
      PRINT *, 'HOURS AND GRADE?'
      READ *, HOURS, GRADE

* While HOURS > 0.0 do the following
10    IF (HOURS .GT. 0.0) THEN
          NEWHRS = NEWHRS + HOURS
          NEWPTS = NEWPTS + HOURS * GRADE
          PRINT *, 'HOURS AND GRADE?'
          READ *, HOURS, GRADE
      GO TO 10
      END IF

      IF (NEWHRS .EQ. 0.0) THEN
          CURGPA = 0.0
      ELSE
          CURGPA = NEWPTS / NEWHRS
      END IF
      GPASUM = GPASUM + CURGPA
      CUMHRS = CUMHRS + NEWHRS
      CUMGPA = (OLDPTS + NEWPTS) / CUMHRS
      NUMSTU = NUMSTU + 1
      END


** CHECK **************************************************************
      SUBROUTINE CHECK

      PRINT *, '*********** CHECK CALLED ***********'
      END

** REPORT *************************************************************
      SUBROUTINE REPORT(SNUMB, CLASS, CUMHRS, CURGPA, CUMGPA)

      INTEGER SNUMB, CLASS
      REAL CUMHRS, CURGPA, CUMGPA

      PRINT *, '*********** REPORT CALLED ***********'
***** Temporary printout *****
      PRINT *, 'SNUMB: ', SNUMB
      PRINT *, 'CLASS: ', CLASS
      PRINT *, 'CUM. HOURS: ', CUMHRS
      PRINT *, 'CURR. GPA:  ', CURGPA
      PRINT *, 'CUM. GPA:   ', CUMGPA
      END

