/* The following program reads student data into structure arrays,
   uses functions to compute lab averages of each student, and
   find a student based on user input. The functions are in seperate
   files. There is also function to write data into a file */
*/

#include <stdio.h>
#include <string.h>
#define SIZE 80


struct student_struct {

    char name[20];
    int status;
    int hw;
    int labs[12];
    int progs[3];
    int mids[2];
    int final;
    float labavg;
};

#include "read.c"
#include "write.c"
#include "labavg.c"
#include "find_student.c"


void read_data(struct student_struct *, int);
void write_data(struct student_struct *, int);
void lab_avg(struct student_struct *, int);
int  find_student(struct student_struct *,char [],int);


main()
{
  
  char name[50];
  int index;

  struct student_struct student[SIZE];
  
  read_data(student,SIZE);
  lab_avg(student,SIZE);

/* This block would get the student name and then call a function to
   get back the index of that student in the structure array */

  printf("Type in the student's name to find the data:");
  
  scanf("%s",name);
  
  index=find_student(student,name,SIZE);

  printf("The lab average is: %f\n",student[index].labavg);

  write_data(student,SIZE);

}


