#include <stdio.h>

#include <stdlib.h>

#include <string.h>

typedef struct { // define the student structure type

long id ;

char name [ 25 ] ;

int age ;

char department [ 5 ] ;

int grade ;

} student ;

void add_student ( long id ) {

student new ; // create new structure of type 'student'

int i ;

new. id = id ;

printf ( "

Great! Now enter the student's name: " ) ;

fgets ( new. name , 26 , stdin ) ;

printf ( "%s" , new. name ) ;

}

void menu_options ( int x )

{

/* use switch statement and user input value from function 'main'

to determine which linked list to enter */

long id ;

switch ( x ) {

case 1 : // user inputs '1' indicating 'add student'

puts ( "To add a student, enter the ID number of the New Student: " ) ;

scanf ( "%ld" , & id ) ;

add_student ( id ) ;

break ;

case 2 : // user inputs '2' indicating 'modify student'

puts ( "Modify" ) ;

break ;

case 3 : // user inputs '3' indicating 'delete student'

puts ( "Delete" ) ;

break ;

case 4 : // user inputs '4' indicating 'list students by department'

puts ( "List" ) ;

break ;

case 5 : // user inputs '5' indicating 'print student averages'

puts ( "Print" ) ;

break ;

case 6 : // user inputs '6' indicating 'exit'

puts ( "exit" ) ;

break ;

default : // user input does not match above cases (shouldn't happen)

break ;

}

}

void menu_test_input ( int x ) {

if ( 0 < x && x < 7 ) { // send value to function 'menu_options'

menu_options ( x ) ;

}

else { // retest if invalid input

printf ( "Sorry, that input is invalid. Please enter a number that indicates a menu item.

" ) ;

scanf ( "%d" , & x ) ;

menu_test_input ( x ) ;

}

}

int main ( )

{

int item ;

printf ( "Type the number of desired menu item



" ) ; // print menu items

printf ( "1. Add Student

" ) ;

printf ( "2. Modify Student

" ) ;

printf ( "3. Delete Student

" ) ;

printf ( "4. List Students by Department

" ) ;

printf ( "5. Print Student Averages

" ) ;

printf ( "6. Exit



" ) ;

scanf ( "%d" , & item ) ; // retrieve an integer value from the user, assign to variable 'item'

menu_test_input ( item ) ;

return 0 ;