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

Programming languange is C 2. No usage of global variables. All data must be pas

ID: 3798257 • Letter: P

Question

Programming languange is C

2. No usage of global variables. All data must be passed or received via function parameters.

3. Write short and simple functions.

4. Using separate files – Create four C (*.c) files and four header files (*.h)

4.1. uni.c – containing the main program (containing main(argc, argv)). 4.2. student files – two files: student.c will contains all the functions for handling student records (e.g., entering student data, printing a student record or searching students by name); student.h will contain the declaration of functions (function prototype) and data.h

4.3. employee files – two files employee.c and employee.h which will contain employee related data. Employee.h will contain the file data.h

4.4. data.h – a file containing the declaration of the three structures (student, employee and person)

1) Suggestions

a) As you code your small helping functions write small test functions to ensure that the code is correct. This will allow you to focus on the logic of your program without worrying about the simple functions. In particular make sure that you have a few functions that check the validity of the input.

b) Create function for each menu option. The function should accept as input the array of person and the number of elements in the array.

Question 1

Tasks 1. Creating student, employee, person structures (10 pts)

Here you will create the structures to be used by the program. Make sure that you pack the structure as small as possible (reduce the footprint). Use bit fields to represent small ranges.

1.1 Create a student structure consisting of the student’s fields: GPA, number of courses, and tuition fees.

1.2. Create an employee structure consisting of the employee’s fields: Salary, years of service, and level.

1.2.1. Structure name is struct employee

1.3. Create a person structrue that consists of the common records: first name, family name and telephone and a union between the student and employee record. Make sure that you add a field to discriminate between the employee and student substructures.

1.3.1. Structure name is struct person

1.4. Create an array that can hold 20 records of person. The array name is person

2. Menu (5 pts)

Create a menu function that will allow the user to manipulate the lists.

2.1. Create a menu function (int menu()) which will return the menu option that the user has selected.

2.2. Display the menu options:

2.2.1. 1. Add a new Employee

2.2.2. 2. Add a new student

2.2.3. 3. Print all employees

2.2.4. 4. Print all students

2.2.5. 5. Search students using Family Name

2.2.6. 6. Summary of Data

2.2.7. 0. Quit

2.3. The program will display the menu to the user and ask the user to enter an option. If the selected option is valid that the system will execute the option. Otherwise, the system will prompt the user that the option is not valid and then redisplay the menu.

3. Menu actions

3.1. (5 pts) Create a switch statement in the main function, which will process the menu item selected by the user. Each “case” will invoke a corresponding function that will execute one of the actions described in 3.2

3.8. Here you will be responding to the action selected by the user as follows. Allow the user to enter up to 20 records.

3.2. Add a new student record (20 pts) – here the program will prompt the user to enter the person information. In doing so the program will have to check whether the input is correct. If the input is incorrect then the program will ask the user to re-enter the information.

3.2.1. The system shall ask the user to enter the first name. If the given name is too long then copy only the first k characters where k is the number of characters in the structure.

3.2.2. The system shall ask the user to enter the family name. If the given name is too long then copy only the first k characters where k is the number of characters in the structure.

3.2.3. The system shall ask the user to enter the telephone number. (The system should check for a valid phone number – all digits 0-9 and the first digit cannot be 0 or 1.

3.2.4. Enter Student fields The system should prompt the user to enter the student fields

3.2.5. Student’s fields (check ranges)

3.2.5.1. Enter GPA – check for range

3.2.5.2. Enter Tuition Fees

3.2.5.3. Enter number of courses – check for range

3.3. Add a new employee (20 pts)

3.3.1. The system shall ask the user to enter the first name. If the given name is too long then copy only the first k characters where k is the number of characters in the structure.

3.3.2. The system shall ask the user to enter the family name. If the given name is too long then copy only the first k characters where k is the number of characters in the structure.

3.3.3. The system shall ask the user to enter the telephone number. (The system should check for a valid phone number – all digits 0-9 and the first digit cannot be 0 or 1.

3.3.4. Employee fields – (check ranges) The system should prompt the user to enter the employee fields

3.3.4.1. Enter salary 3.3.4.2. Enter years of service

3.3.4.3. Enter level

3.4. Print students list (5pts) Print all the students. Hint – create a function to print a student.

Print format; First Name Family Name (33 char), Tel: xxxxxxxxxx, GPA:xxx, Courses:xxx, Tuition: xxxxx.xx

For example:

John Dilbert Tel: 6135202600, GPA: 7, Courses: 13, Tuition: 3450.34

Jane Smith Tel: 6135202600, GPA: 10, Courses: 15, Tuition: 3450.00

3.5. Print the employee record (5pts)

Print all the employees. Hint – create a function to print an employee.

Print format: First Name Family Name (33) characters, Tel: xxxxxxxxxx, Age:xxx, Level:xxx, Salary:xxxxxx.xx

For example ;

John Dilbert Tel: 6135202600, Age: 58, Level: 13, Salary: 450.34

Jane Smith Tel: 6135202600, Age: 47, Level: 10, Salary:133450.00

3.6. Finds student by Family Name (5pts)

3.6.1. Prompt the user to enter a family name

3.6.2. Search the list for all students with a matching family name and print their record as above

3.7. Summary of Records (25 pts)

here you will provide a summary of all the information that is available

Output:

Total number of records: xx

Students Stats:

Number of students: xx

Average GPA: xx.xx, Average Number of courses: xx.xx, Average Tuition Fees: xxxx.xx

Employees Stats:

Number of employees: xx Min Level: xx Max Level: xx

Average Age: xx.xx, Average Salary: xxxxx.xx

3.8. Quit (5 pts)

3.8.1. Warn the user that he/she is about to quit and ask whether to proceed (y/n)

Screenshot 2017-02-25 10.20.33 png Photos Screenshot 2017-02-25 10,20,47png Photos Ask me anything Screenshot 2017-02-25 10.21.02 png Photos 17-02-25 10.21.09 png Photos ENG 10:42 AM US 2017-02-25

Explanation / Answer

main.c

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "menu.h"

int menu(){

   char choice[100];
   int choiceInt;
   int done;

   done = 0;

   while(done == 0){
       //print menu
       printf(" ");
       printf("1. Add a new Record ");
       printf("2. print Student List ");
       printf("3. print employee List ");
       printf("4. Find a students using GPA ");
       printf("5. Find student using Family Name ");
       printf("6. Find employees using salary ");
       printf("7. Find employees using Family Name ");
       printf("8. Summary of Data ");
       printf("9. Fix max GPA using pointers ");
       printf("0. Quit ");
       printf(" ");

       //wait for response
       printf("Choice: ");
       scanf("%s[^ ] ", choice);


       //check response
       if(isInt(choice) == 0){
           //printf("The integer test passed. %s ", choice);
           sscanf(choice,"%d",&choiceInt);
           if(choiceInt >= 0 && choiceInt <= 9){
               done = 1;
           }else{
               printf("The choice enter is out of range. Please choose again. ");
           }
          
       }else{
           //respone out of bound so choose again
           printf("The option you selected is not valid. Please choice an option again. ");
       }
   }

   return choiceInt;

}

common.c

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "ctype.h"

#include "student.h"
#include "employee.h"

void getTelephone(struct person *p){
   int collected;
   collected = 0;

   while(collected != 1){
       printf("Please enter the telephone number for the record: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);

       if (charRead == 0){
           printf("Error in reading telephone. ");
       } else{
           if(isTelephone(inputStr)==0){
               //printf("Inside loop ");
               sscanf(inputStr,"%s",p->telephone);
               printf("Telephone Saved. ");
               //free(inputStr);
               collected = 1;
           }else{
               printf("The telephone entered does not follow the correct fromat. ");
               printf("The field only takes numbers 0-9 and the first digit is not allowed to be 0 or 1. ");
               printf("Acceptable formats include: ");
               printf("########## ");
           }
       }
   }
}


void getFirstName(struct person *p){
   int collected;
   collected = 0;

   while(collected != 1){
       printf("Please enter First Name: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);
       if (charRead == 0){
           printf("Error in reading First Name. ");
       } else{
           if(isString(inputStr)==0){
               strncpy(p->fn, inputStr, 10);
               printf("First Name Saved. ");
               //free(inputStr);
               //flushall();
               collected = 1;
           }else{
               printf("The First Name entered does not follow the correct fromat. ");
               printf("The field only takes alphabets as inputs. No numericals are allowed. ");
               printf("Acceptable formats include: ");
               printf("John ");
               printf("Alex ");
               printf("SueMun ");
           }
       }
   }
}

void getLastName(struct person *p){
   int collected;
   collected = 0;

   while(collected != 1){
       printf("Please enter Family Name: ");

       char inputStr[100];

       char charRead = scanf("%s[^ ] ",inputStr);
       if(charRead == 0){
           printf("Error in Family Name. ");
       }else{
           if(isString(inputStr)==0){
               strncpy(p->ln, inputStr, 20);
               printf("Family Name Saved. ");
               collected = 1;
           }else{
               printf("The Family Name entered does not follow the correct fromat. ");
               printf("The field only takes alphabets as inputs. No numericals are allowed. ");
               printf("Acceptable formats include: ");
               printf("Doe ");
               printf("Brown ");
               printf("Chi ");
           }
       }
   }
}

void getDiscriminator(struct person *p){
   int collected;
   collected = 0;

   while(collected != 1){
       printf("Is this record a student record? Please enter "y" or "n": ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);
       //getchar();
       if (charRead == 0){
           printf("Error in Family Name. ");
       } else{
           if(isString(inputStr)==0){
               if (strncmp(inputStr,"y",1)==0){
                   p->discriminator = 1;
               }else if(strncmp(inputStr,"n",1)==0){
                   p->discriminator = 0;
               }
               printf("Record Status Saved. ");
               //free(inputStr);
               collected = 1;
           }else{
               printf("Please enter only y or n. No other inputs need to be entered. ");
           }
       }
   }
}

int isFloat(char *s){

}

int isString(char *s){
   int i = 0;

   for(i = 0; i < strlen(s); i++){
       char c = s[i];
       //printf("%c ",c );
       if((c>='a'&& c<='z') || (c>='A' && c<='Z') || (c == ' ')){

       }else{
           return -1;
       }
   }

   return 0;
}

int isInt(char *s){
   int i;
  
   for(i = 0; i < strlen(s); i++){
       char c = s[i];
       //printf("%c ",c );
       if(c>='0'&& c<='9'){

       }else{
           return -1;
       }
   }

   return 0;
}

int isTelephone(char *s){
  
   char first;
   first = s[0];
   //printf("First Char is: %c ", first);
   if(first == '0' || first == '1'){
       //printf("Cause first number: %c ", first);
       return -1;
   }else if(isInt(s)==0 && strlen(s)==10){
       return 0;
   }else{
       return -1;
   }
}


void summaryMaker(struct person p[], int size){
   int totalRecords = 0;

   int stuNum = 0;
   int totalGPA = 0;
   int totalCourses = 0;
   int totalTuition = 0;

   int empNum = 0;
   int minLevel = 15;
   int maxLevel = 0;
   int totalAge = 0;
   int totalSalary = 0;

   int i;
   for(i = 0; i < size; i++){
       totalRecords++;
       if(p[i].discriminator == 1){
           stuNum++;
           totalGPA += p[i].info.stu.gpa;
           totalCourses += p[i].info.stu.courses;
           totalTuition += p[i].info.stu.tuition;
       }else{
           empNum++;
           totalAge += p[i].info.emp.yos;
           totalSalary += p[i].info.emp.salary;
           if(p[i].info.emp.level > maxLevel){
               maxLevel = p[i].info.emp.level;
           }
           if(p[i].info.emp.level < minLevel){
               minLevel = p[i].info.emp.level;
           }
       }
   }

   float avergaeGPA = totalGPA/stuNum;
   float avgCourses = totalCourses/stuNum;
   float avgTuition = totalTuition/stuNum;

   printf("Total number of records: %d ", totalRecords);
   printf("Student Stats: ");
   printf("Number of Students: %d ", stuNum);
   printf("Average GPA: %.2f", avergaeGPA);
   printf(", Average Number of courses: %.2f", avgCourses);
   printf(", Average Tutition Fees: %.2f ", avgTuition);


   float avgAge = totalAge/empNum;
   float avgSal = totalSalary/empNum;

   printf("Employees' Stats: ");
   printf("Number of Employees: %d ", empNum);
   printf("Max Level: %d", maxLevel);
   printf("   Min Level: %d ", minLevel);
   printf("Average Age: %.2f", avgAge);
   printf(", Average Salary: %.2f ", avgSal);
}


int quitChecker(){
   int collected;
   collected = 0;

   while(collected != 1){
       printf("Do you really want to quit? Please enter "y" or "n": ");

       char inputStr[100];

       int charRead = scanf("%s", &inputStr);
       if (charRead == 0){
           printf("Error in Quit read. ");
       } else{
           if(isString(inputStr)==0){
               if (strncmp(inputStr,"y",1)==0){
                   return 0;
               }else if(strncmp(inputStr,"n",1)==0){
                   return -1;
               }
               free(inputStr);
               collected = 1;
           }else{
               printf("Please enter only y or n. No other inputs need to be entered. ");
           }
       }
   }
}

struct person getNewRecord(){
   struct person thisPerson;

   getFirstName(&thisPerson);
   getLastName(&thisPerson);
   getTelephone(&thisPerson);
   getDiscriminator(&thisPerson);

   if (thisPerson.discriminator == 1){
       getStudent(&thisPerson);
   }else{
       getEmployee(&thisPerson);
   }

   return thisPerson;

}

data.h


#ifndef _data_h
#define _data_h

struct student{
   unsigned int gpa:4;
   unsigned int courses:6;
   float tuition;
};

struct employee{
   unsigned int level:4;
   unsigned int yos:6;
   float salary;
};

union trait{
   struct student stu;
   struct employee emp;
};

struct person{
   char *fn[10];
   char *ln[20];
   char *telephone[10];
   unsigned int discriminator:1;
   union trait info;
};

#endif

employee.c

#include "stdio.h"
#include "stdlib.h"
#include "string.h"

#include "math.h"
#include "employee.h"


void getLevel(struct person *p){
   int collected;
   collected = 0;

   while(collected != 1){
       printf("Please enter the employee level: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);

       if (charRead == 0){
           printf("Error in reading level. ");
       } else{
           if(isValidLevel(inputStr)==0){
               int a;
               sscanf(inputStr,"%d",&a);
               p->info.emp.level = a;
               printf("Level Saved. ");
               //free(inputStr);
               collected = 1;
           }else{
               printf("The level you entered is incorrect. Please fix. ");
               printf("The acceptable integer values of level are between 1 - 15. ");
           }
       }
   }
}

int isValidLevel(char *input){
   if(isInt(input) == 0){
       int a;
       sscanf(input,"%d",&a);
       if(a >= 1 && a <= 15){
           return 0;
       }else{
           return -1;
       }
   }else{
       return -1;
   }
}

void getYOS(struct person *p){
   int collected;
   collected = 0;

   while(collected != 1){
       printf("Please enter the employee's years of service: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);

       if (charRead == 0){
           printf("Error in reading Years of Service. ");
       } else{
           if(isValidYOS(inputStr)==0){
               int a;
               sscanf(inputStr,"%d",&a);
               p->info.emp.yos = a;
               printf("Years of Service Saved. ");
               //free(inputStr);
               collected = 1;
           }else{
               printf("The Years of Service you entered is incorrect. Please fix. ");
               printf("The acceptable integer values of Years of service is between 0 - 63. ");
           }
       }
   }
}

int isValidYOS(char *input){
   if(isInt(input) == 0){
       int a;
       sscanf(input,"%d",&a);
       if(a >= 0 && a <= 63){
           return 0;
       }else{
           return -1;
       }
   }else{
       return -1;
   }
}

void getSalary(struct person *p){
   int collected;
   collected = 0;

   while(collected != 1){
       printf("Please enter the employee salary: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);

       if (charRead == 0){
           printf("Error in reading employee salary. ");
       } else{
           if(isValidSalary(inputStr)==0){
               float a;
               sscanf(inputStr,"%.2f",&a);
               a = roundf(a * 100) / 100;
               p->info.emp.salary = a;
               printf("Salary Saved. ");
               //free(inputStr);
               collected = 1;
           }else{
               printf("The salary you entered is incorrect. Please fix. ");
               printf("Salary must contain only numbers and must be positive. ");
               printf("It can have a decimal point in it. ");
           }
       }
   }
}

int isValidSalary(char *s){

   int numOfDecimals = 0;
   int i;

   for (i = 0; i < strlen(s); i++){
       char c;
       c = s[i];
       //printf("%c ", c);
       if (c == '.'){
           numOfDecimals++;
           if(numOfDecimals > 1){
               return -1;
           }
       }else{
           if((c>='a'&& c<='z') || (c>='A' && c<='Z')){
               return -1;
           }
       }
   }

   return 0;
}


//PRINT AN EMPLOYEE STUFF

void printEmployee(struct person p){
   char *fir = p.fn;
   char *sec = p.ln;
   char *thi = p.telephone;
  
   int forth = p.info.emp.yos;
   int fifth = p.info.emp.level;
   float sixth = p.info.emp.salary;
   sixth = roundf(sixth * 100) / 100;


   printf("%s %s        Tel: %s,   Age: %d,       Level: %d,       Salary: %.2f ", fir, sec, thi,forth,fifth,sixth );

}

void printAllEmployees(struct person person[], int size){

   //printf("FirstName SecondName        Tel: xxxxxxxxxx,   Age: xx,       Level: xx,       Salary: xxxxx.xx ");
   int i;
   for(i = 0; i < size; i++){
       if(person[i].discriminator == 0){
           printEmployee(person[i]);
       }
   }
   printf("--End of Print-- ");
}


void printAllEmployeeWithSalary(struct person person[], int size){

   int collected;
   collected = 0;

   while(collected != 1){

       printf("Please enter the Salary you want to search with: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);

       if(isValidSalary(inputStr) == 0){
           int i;
           float ab;
           sscanf(inputStr,"%f",&ab);
           for(i = 0; i < size; i++){
               //printf("Entered the checking loop ");
               if(person[i].discriminator == 0 && person[i].info.emp.salary == ab){
                   printEmployee(person[i]);
               }
           }
           printf("--End of Search-- ");
           collected = 1;
       }else{
           printf("That was an invalid Salary Amount. Please try again. ");
           printf("Salary must contain only numbers and must be positive. ");
           printf("It can have a decimal point in it. ");
       }
   }
}


void printAllEmployeeWithFamilyName(struct person person[], int size){
   int collected;
   collected = 0;

   while(collected != 1){

       printf("Please enter the Employee Family Name you want to search with: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);

       if(isString(inputStr) == 0){
           int i;
           for(i = 0; i < size; i++){
               if(person[i].discriminator == 0 && strcmp(person[i].ln,inputStr) == 0){
                   printEmployee(person[i]);
               }
           }
           printf("--End of Search-- ");
           collected = 1;
       }else{
           printf("The family name entered is incorrect. Please try again. ");
           printf("The field only takes alphabets as inputs. No numericals are allowed. ");
           printf("Acceptable formats include: ");
           printf("Doe ");
           printf("Brown ");
           printf("Chi ");
       }

   }

  
}

void getEmployee(struct person *peep){

   getLevel(peep);
   getYOS(peep);
   getSalary(peep);

}


employee.h

#ifndef _emp_h
#define _emp_h

#include "employee.c"

void getLevel(struct person *p);
int isValidLevel(char *input);
void getYOS(struct person *p);
int isValidYOS(char *input);
void getSalary(struct person *p);
int isValidSalary(char *s);
void getEmployee(struct person *peep);

void printEmployee(struct person p);
void printAllEmployees(struct person person[], int size);
void printAllEmployeeWithSalary(struct person person[], int size);
void printAllEmployeeWithFamilyName(struct person person[], int size);


#endif

menu.h


#ifndef _menu_h
#define _menu_h

#include "menu.c"

int menu();


#endif

student.c

#include "stdio.h"
#include "stdlib.h"
#include "string.h"

#include "math.h"
#include "student.h"


//MAKE A STUDENT STUFF

void getGPA(struct person *p){
   int collected;
   collected = 0;

   while(collected != 1){
       printf("Please enter the Student GPA: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);
       printf("Entered Value: %s ", inputStr);
       if (charRead == 0){
           printf("Error in reading gpa. ");
       } else{
           if(isValidGPA(inputStr)==0){
               int ab;
               sscanf(inputStr,"%d",&ab);
               p->info.stu.gpa = ab;
               printf("GPA Saved. ");
               collected = 1;
           }else{
               printf("The GPA you entered is incorrect. Please fix. ");
               printf("The acceptable integer values of GPA are between 0 - 10. ");
           }
       }
   }
}

int isValidGPA(char *input){
   if(isInt(input) == 0){
       //printf("%d ", isInt(input,100) );
       int a;
       sscanf(input,"%d",&a);
       if(a >= 0 && a <= 10){
           return 0;
       }else{
           return -1;
       }
   }else{
       return -1;
   }
}

void getCourses(struct person *p){
   int collected;
   collected = 0;

   while(collected != 1){
       printf("Please enter the Student number of Courses: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);

       if (charRead == 0){
           printf("Error in reading courses. ");
       } else{
           if(isValidCourses(inputStr)==0){
               int ab;
               sscanf(inputStr,"%d",&ab);
               p->info.stu.courses = ab;
               printf("Courses Saved. ");
               collected = 1;
           }else{
               printf("The course number you entered is incorrect. Please fix. ");
               printf("The acceptable integer values of courses is between 0 - 40. ");
           }
       }
   }
}

int isValidCourses(char *input){
   if(isInt(input) == 0){
       int a;
       sscanf(input,"%d",&a);
       if(a >= 0 && a <= 40){
           return 0;
       }else{
           return -1;
       }
   }else{
       return -1;
   }
}

void getTuition(struct person *p){
   int collected;
   collected = 0;

   while(collected != 1){
       printf("Please enter the Student Tuition fees: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);

       if (charRead == 0){
           printf("Error in reading tuition. ");
       } else{
           if(isValidTuition(inputStr)==0){
               float a;
               sscanf(inputStr,"%.2f",a);
               a = roundf(a * 100) / 100;
               p->info.stu.tuition = a;
               printf("Tuition Saved. ");
               collected = 1;
           }else{
               printf("The tuition fees you entered is incorrect. Please fix. ");
               printf("Tuition must contain only numbers and must be positive. ");
               printf("It can have a decimal point in it. ");
           }
       }
   }
}

int isValidTuition(char *s){
   int numOfDecimals = 0;
   int i;

   for (i = 0; i < strlen(s); i++){
       char c;
       c = s[i];
       //printf("%c ", c);
       if (c == '.'){
           numOfDecimals++;
           if(numOfDecimals > 1){
               return -1;
           }
       }else{
           if((c>='a'&& c<='z') || (c>='A' && c<='Z')){
               return -1;
           }
       }
   }

   return 0;
}

// PRINT A STUDENT STUFF

void printStudent(struct person p){
   //printf("Print Student entered. ");
   char *fir = p.fn;
   char *sec = p.ln;
   char *thi = p.telephone;
  
   int forth = p.info.stu.gpa;
   int fifth = p.info.stu.courses;
   float sixth = p.info.stu.tuition;


   printf("%s %s        Tel: %s,   GPA: %d,       Courses: %d,       Tuition: %.2f ", fir, sec, thi,forth,fifth,sixth );

}

void printAllStudents(struct person person[], int size){
   //printf("FirstName SecondName        Tel: xxxxxxxxxx,   GPA: xx,       Courses: xx,       Tuition: xxxxx.xx ");
   int i;
   for(i = 0; i < size; i++){
       //printf("The loop entered fine. ");
       if(person[i].discriminator == 1){
           //printf("person %d print requested ", i);
           printStudent(person[i]);
       }
   }
   printf("--End of Print-- ");
}

void printAllStudentsWithGPA(struct person person[], int size){

   int collected;
   collected = 0;

   while(collected != 1){

       printf("Please enter the GPA you want to search with: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);

       if(isValidGPA(inputStr) == 0){
           int i;
           int ab;
           sscanf(inputStr,"%d",&ab);
           for(i = 0; i < size; i++){
               //printf("Entered the checking loop ");
               if(person[i].discriminator == 1 && person[i].info.stu.gpa == ab){
                   printStudent(person[i]);
               }
           }
           printf("--End of Search-- ");
           collected = 1;
       }else{
           printf("That was an invalid GPA. Please try again. ");
           printf("The acceptable integer values of GPA are between 0 - 10. ");
       }
   }

}

void printAllStudentsWithFamilyName(struct person person[], int size){
   int collected;
   collected = 0;

   while(collected != 1){

       printf("Please enter the Student Family Name you want to search with: ");

       char inputStr[100];

       int charRead = scanf("%s[^ ] ", inputStr);

       if(isString(inputStr) == 0){
           int i;
           for(i = 0; i < size; i++){
               if(person[i].discriminator == 1 && strcmp(person[i].ln,inputStr) == 0){
                   printStudent(person[i]);
               }
           }
           printf("--End of Search-- ");
           collected = 1;
       }else{
           printf("The family name entered is incorrect. Please try again. ");
           printf("The field only takes alphabets as inputs. No numericals are allowed. ");
           printf("Acceptable formats include: ");
           printf("Doe ");
           printf("Brown ");
           printf("Chi ");
       }

   }  
}

void getStudent(struct person *peep){

   getGPA(peep);
   getTuition(peep);
   getCourses(peep);

}

student.h

#ifndef _stu_h
#define _stu_h

#include "student.c"

void getGPA(struct person *p);
int isValidGPA(char *input);
void getCourses(struct person *p);
int isValidCourses(char *input);
void getTuition(struct person *p);
int isValidTuition(char *s);
void getStudent(struct person *peep);

void printStudent(struct person p);
void printAllStudents(struct person person[], int size);
void printAllStudentsWithGPA(struct person person[], int size);
void printAllStudentsWithFamilyName(struct person person[], int size);

#endif