this is driving me nuts because i dont actually know what time doing with structures.
here is my program discription:
Using modular programming techniques, design and implement a C program to maintain a database
of hospital employee information. The database will store the following information about each
employee: employee number - 5 digits, name - maximum of 20 characters, age - integer, and
department (‘E’ for Emergency, ‘O’ for Orthopaedics, ‘M’ for Maternity, and ‘G’ for General
Surgery). The hospital employee database is to be implemented as an ARRAY of structures.
Use the following structure definition
struct employ_rec {
long int empnum;
char name[21];
char dept;
int age;
};
Then in your main program, declare your database similar to:
struct employ_rec hospital[50];
int numemps = 0;
The main program is to repeatedly prompt the user for input and then call the appropriate module
to deal with the request (i.e., a menu system). The legal commands in your system are:
‘A’ or ‘a’
(numemps) The routine which handles this command should prompt the user
for the all employee information. The procedure should also only input
- Add one employee to your database and add 1 to the database counteroneemployee (i.e. there should NOT be a loop in the function which allows the user
to enter more than one employee at this time). To input 2 employees requires
that the user use the
type of information input just not the correct set of values (i.e, you will get an
integer entered for employee number however it may be negative). Also be sure
to check that same employee number is not input twice.
void InsertData(struct employ_rec hospital[], int &numemps)
‘P’ or ‘p’
void PrintData(struct employ_rec hospital[], int num)
‘C’ or ‘c’
number of which employee to change, the type of information to change (‘A’ for
Age, or ‘D’ for Department’), and the new information to be inserted. Be sure
to print an error message if the employee does not exist. Also, you can assume
that the proper type of information is given but not a correct value.
void ChangeData(struct employ_rec hospital[], int num)
‘Q’ or ‘q’
A command twice. As always, you can assume the correct- Neatly print the employee information in a table (does not have to be sorted).- Change the employee information. This routine should prompt for the employee- Quit the program.
Not bad, but what i wrote has 2 major errors that i cant grasp.
here is my code (with the major error areas in bold)
*next post*