// july17ex2.cpp : Defines the entry point for the console application.
// gpa with count of hi ties and lo ties

#include "stdafx.h"
#include "stdlib.h"
#include "time.h"
#define num_stu 40


int main(int argc, char* argv[])
{
   int which, hi_stu, hi_count, lo_stu, lo_count;
   float gpa, hi_gpa=-99.9, lo_gpa=100.0, tot_gpa=0.0;
   srand(time(NULL));


   for (which=1; which<= num_stu; which++){

	   gpa = float (rand() % 41) / 10;  /* only gpa in tenths of points */
	   tot_gpa = tot_gpa + gpa;

	   if (gpa > hi_gpa)  {
                hi_gpa = gpa;
				hi_stu = which;
				hi_count = 1;
	   } /* end if gpa */
	   else if (gpa == hi_gpa) hi_count++;

	   if (gpa < lo_gpa)  {
                lo_gpa = gpa;
				lo_stu = which;
				lo_count = 1;
	   } /* end if gpa */
	   else if (gpa == lo_gpa) lo_count++;

	   printf("Student %2d had gpa of %4.2f\n", which, gpa);


   }  /*end for which  */


   printf("The average gpa was %4.2f\n", tot_gpa/num_stu );
   printf("The highest gpa was %4.2f belonging to student num %d\n",
	         hi_gpa, hi_stu);
   printf("There were %d students who tied for highest\n\n", hi_count);

   printf("The lowest gpa was %4.2f belonging to student num %d\n",
	         lo_gpa, lo_stu);
   printf("There were %d students who tied for lowest\n\n", lo_count);

	return 0;
}