Question: I provided the pictures and the required code to finish up in a C programming language. Codes are seperates by **** and the name of

I provided the pictures and the required code to finish up in a C programming language. Codes are seperates by **** and the name of each files .c and .h are in bold characther. To make it easier to understand.

I provided the pictures and the required code to finish up in

a C programming language. Codes are seperates by **** and the name

of each files .c and .h are in bold characther. To make

it easier to understand. In The C programming language: first file is

employee.c ******************************************************************************************************************************************* #include "employee.h" #include "stdio.h" void printEmployee(PersonRec person) { //print the

employee first and family name printf("%-15s",person.first_name); printf("%-15s",person.family_name); } void printEmployees(PersonRec *person, int

numRecords) { // add code } void printEmployeesSummary(PersonRec *person, int numRecords) {

// add code } second file is: employee.h ******************************************************************************************************************************************* // file is

emoloyee.h // include files #include "struct.h" // function prototypes void printEmployees(PersonRec *person,

In The C programming language:

first file is employee.c

*******************************************************************************************************************************************

#include "employee.h" #include "stdio.h"

void printEmployee(PersonRec person)

{ //print the employee first and family name printf("%-15s",person.first_name); printf("%-15s",person.family_name);

}

void printEmployees(PersonRec *person, int numRecords) {

// add code

}

void printEmployeesSummary(PersonRec *person, int numRecords) {

// add code

}

second file is: employee.h

*******************************************************************************************************************************************

// file is emoloyee.h

// include files #include "struct.h" // function prototypes

void printEmployees(PersonRec *person, int numRecords); void printEmployeesSummary(PersonRec *person, int numRecords);

third file is hospital.c

*******************************************************************************************************************************************

#include "stdio.h" #include "stdlib.h" #include "struct.h" #include "string.h" #include "populateRecords.h" #include "patient.h" #include "employee.h"

#define NUM_RECORDS 20

int main() { struct person person[NUM_RECORDS]; char rc = 0;

// populating the array person with data of patients and employees populateRecords(person, NUM_RECORDS);

// add code here //

return 0; }

fourth file is patient.c

*******************************************************************************************************************************************

#include "string.h" #include "stdio.h" #include "patient.h"

void printPatient(PersonRec person)

{

// add code

}

void printPatients(PersonRec *person, int numRecords) {

// add code

}

void printPatientSummary(PersonRec *person, int numRecords) {

// add code

}

void searchPatient(PersonRec *person, int numRecords)

{

// add code

}

fifth file is patient.h

*******************************************************************************************************************************************

// file is patient.h

// include files #include "struct.h"

/******************************************************/ // function prototypes

void printPatients(PersonRec *person, int numRecords); void printPatientSummary(PersonRec *person, int numRecords); void searchPatient(PersonRec *person, int numRecords); void printPatientSummary(PersonRec *person, int numRecords);

sixth file is populateRecords.c

*******************************************************************************************************************************************

//INCLUDES

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

//FUNCTION PROTOTYPES

void populateEmployee(EmployeeRec *employee); void populatePatient(PatientRec *patient);

/* populates an employees

input

emp - an employee record

output emp - populated employee

*/

// DEFINES

#define MAX_YEARS_SERVICE 63 #define MAX_SALARY 300000

void populateEmployee(EmployeeRec *emp) {

emp->salary = (rand() % MAX_SALARY) * 1.34f ; emp->yearsService = rand() % MAX_YEARS_SERVICE+1; emp->department = rand() % MAX_DEPARTMENTS + 1; emp->position = rand() % MAX_POSITIONS;

}

/* populate a patient record

input patient - a student record

output patient - a student record

*/

#define MAX_DAILY_COST 50 #define MAX_DAYS_IN_HOSPITAL 30

void populatePatient(PatientRec *p) {

p->department = rand() % MAX_DEPARTMENTS + 1; p->dailyCost = rand() % MAX_DAILY_COST+5; p->severity = rand() % NUM_SEVERITIES; p->numDaysInHospital = rand() % MAX_DAYS_IN_HOSPITAL+1;

}

/* populate an employee record

input person - an array of persons numPersons - number of person in the array

output emp - array of employees

assumption: numPersons is

char *fn[NUM_NAMES] = { "John", "Jane", "David", "Dina", "Justin","Jennifer", "Don" }; char *sn[NUM_NAMES] = { "Smith", "Johnson", "Mart", "Carp", "Farmer","Ouster","Door" };

if (!initRandom) { initRandom++;

}

while (i firstName[NAME_SIZE - 1] = '\0'; strncpy(person->firstName, fn[j], NAME_SIZE - 1); j = rand() % NUM_NAMES; person->familyName[NAME_SIZE - 1] = '\0'; strncpy(person->familyName, sn[j], sizeof(person->familyName) - 1); if (rand() % 2) { person->emplyeeOrPatient = PATIENT_TYPE; populatePatient(&person->patient); } else { populateEmployee(&person->emp); person->emplyeeOrPatient = EMPLOYEE_TYPE; } person++; i++; } }

*******************************************************************************************************************************************

seventh file is populateRecords.h

// File populateRecords.h /* Purpose: populate the records of the patient and the employee

The user can populate the reocrds of an array of tyupe person.

*/

#ifndef POPULATE_ARRAY_HEADER #define POPULATE_ARRAY_HEADER

#include "struct.h"

void populateRecords(PersonRec *person, int numRecords); // parameter: person and array of person records, nuMRecords the array size

#endif

eight and final file is struct.h

*******************************************************************************************************************************************

// file is struct.h #ifndef STRUCT_HEADER #define STRUCT_HEADER

//DEFINES

#define NAME_SIZE 64 // size of array for patient/employee name (maximum name length is NAME_SIZE - 1)

//Patient related defines #define PATIENT_TYPE 1 // determine that the record is a patient record #define NUM_SEVERITIES 4 // number of different states of a patient #define LIGHT 0 #define STABLE 1 #define ACCUTE 2 #define IMMEDIATE_SURGERY 3

//Employee related defines #define EMPLOYEE_TYPE 0 // determines that the record is an employee record #define MAX_POSITIONS 4 // number of different positions #define DOCTOR 0 #define NURSE 1 #define SURGEON 2 #define ADMIN 3

// Department defines #define MAX_DEPARTMENTS 6

// structure contains patient information typedef struct patient { int department; // department in hospital long dailyCost; // cost of hospitalization per day short numDaysInHospital; // number of days in hospital char severity; // severity of illness } PatientRec;

// structure contains employee information typedef struct employee { int position; // position of employee in hospital; long yearsService; // years of service unsigned long department; // department in hospital float salary; // annual salary } EmployeeRec;

// structure contains person information typedef struct person { char firstName[NAME_SIZE]; char familyName[NAME_SIZE]; char emplyeeOrPatient; union { EmployeeRec emp; PatientRec patient;

}; } PersonRec;

#endif

*************************************************** Hopefully everything is clear and comprehensive.

Grading 10 points for a readme file o 1 point for Purpose of software o 1 point for the developer name and development date o 2 points for description on how the software is organized (partitioned into files) o 2 points for instruction on how to compile the program (give an example) o 1 point for any issues/limitations problem that the user must be aware of o 2 points for instructions explaining how to use the software 5 points for proper submission of files submitting a single tar file and a single readme file using correct file names o o 10 points for using good program layout o Adding small functions as needed o Easy to read/review code o Code documented properly (e.g., purpose of functions, role of variable/parameters, code flow) o No "mega" functions o No globals Grading: You will be graded with respect to what you have accomplished. Namely, you earn points for working code and functionality Coding Instructions: 1. Comments in Code - as provided in the slides given in class 2. No usage of global variables. All data must be passed or received via function parameters. 3. Write short and simple functions. 4. Use separate files - 3 C (*.c) files and four header files .h). The assignment provides the header files and the c files with suggested functions names and prototypes. You do not need to use them if you want to design your software differentl name. To compile the code use gcc hospital.c patient.c employee.c populateRecords.c 4.1. File hospital.c- containing the main program (containing main(arge, argv)) and the menu not use more files then those provide nd do not change the file functionality. The main function is given with a function to populate the array 4.2. Files patient.c and patient.h - file patient.c will contains all functions for handling patient records (e.g., printing data of a patient record or search a patient by name). File patient.h will contain the prototype of the patient functions 4.3. Files employee.c and employee.h file employee.c will contain all functions for handling employee reocrds (e.g., printing an employee reocord). File employee.h wl contain the prototype of the Assignment 3 COMP 2401 Page2 of 11

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!