/* Program to record, print, and process three test scores and final exam scores
   for several students
*/

#include <stdio.h>
#include <string.h>


/* a student struct identifies relevant data for one student */
struct student 
{
   char name[20];
   double test1;
   double test2;
   double test3;
   double final;
};

/* Print a student's name and test record */
void
printStudent (struct student stu)
{
  printf ("%-20s: %7.1lf  %7.1lf  %7.1lf   %7.1lf\n",
	  stu.name, stu.test1, stu.test2, stu.test3, stu.final);
} // printStudent


int
main (void)
{
  /* declaration and initialization of students */
  struct student students[4] = {
                                {"Michael Mouse",      93.2, 98.7, 89.6, 95.6},
                                {"Sebastian the Fish", 75.3, 78.8, 72.6, 92.6},
                                {"Shamrock the Cat",   85.3, 87.2, 78.5, 82.8},
                                {"Inky the Dog",       98.6, 86.9, 69.8, 93.1}
                               };

  /* print initital student records  */
  printf ("Initial student records\n");
  printf ("name                    test 1   test 2   test 3  final exam\n");

  for (int i = 0; i < 4; i++)
  {
    printStudent (students[i]);
  }

  return 0;
} // main
