Please I need help on coding all the function calls as onelarger recursive funct
ID: 3613196 • Letter: P
Question
Please I need help on coding all the function calls as onelarger recursive function, with each item being a separate functioncalled from within the larger recursive function. Thanks
#include<iostream>
#include<string.h>
#include<stdlib.h>
#define FOUND 4
using namespace std;
#define MAX_DOCS 2
#define MAX_OPER 5
#define MAX_PATIENTS 3
#define INITIAL_DOUBLES 0.0
#define INITIAL_INTS 0
#define INITIALCASH_REG 0.00
struct patient
{
char firstname[20];
char lastname[20];
int id;
double savingacct;
int operationid;
int chosendoc;
};
struct doctor
{
char firstname[20];
char lastname[20];
int id;
double checkacctbal;
int countopera;
double clinicsal;
double doc_charges;
};
struct clinic
{
char clinicname[20];
char parentcomp[20];
intoperations[MAX_OPER];
doubledocsalaries[MAX_DOCS];
struct doctor*doc[MAX_DOCS];
struct patient*pat[MAX_PATIENTS];
};
void storeclinicname(FILE *notefile, char *c_name);
void allocdoctor_mem(FILE *notefile, struct clinic *xhosp);
void storedoctor_info(FILE *notefile, struct clinic *xhosp);
void printlist(struct clinic *xhosp);
int main(void)
{
FILE *file;
int m;
struct clinic hosp;
struct patient*xpter;
file = fopen("hw4.dat","r");
if(file == NULL)
{
cout<<"hw4.dat unavailable ";
exit(0);
}
storeclinicname(file,hosp.clinicname);
allocdoctor_mem(file,&hosp);
storedoctor_info(file,&hosp);
printlist(&hosp);
fclose(file);
//PLEASE I NEED HELP ABOVEFUNCTION CALLS TO ONE LARGER RECURSIVE FUNCTION, WITH EACH ITEMBEING A SEPARATE FUNCTION CALLED FROM WITHIN THE LARGER RECURSIVEFUNCTION. THANKS
}
void storeclinicname(FILE *notefile, char *c_name)
{
fscanf(notefile, "%s",c_name);
cout<<c_name<<" is the name of the newclinic. ";
}
void allocdoctor_mem(FILE *notefile, struct clinic *xhosp)
{
int index;
for(index=0;index<MAX_DOCS;index++)
xhosp->doc[index] =new struct doctor;
}
void storedoctor_info(FILE *notefile, struct clinic *xhosp)
{
int index;
for(index=0;index<MAX_DOCS; index++)
fscanf(notefile, "%s %s%d", xhosp->doc[index]->firstname,xhosp->doc[index]->lastname,&(xhosp->doc[index]->id));
}
void printlist(struct clinic *xhosp)
{
int index;
cout<<" Thisis the doctorsinformations -------------------------------- ";
for(index=0;index<MAX_DOCS; index++)
cout<<xhosp->doc[index]->firstname<<xhosp->doc[index]->lastname<<xhosp->doc[index]->id<<endl;
}
PLEASE YOU CAN USE ANY TEXT FILE THANKS
Explanation / Answer
#include#include#include#define FOUND 4using namespace std;#define MAX_DOCS 2#define MAX_OPER 5#define MAX_PATIENTS 3#define INITIAL_DOUBLES 0.0#define INITIAL_INTS 0#define INITIALCASH_REG 0.00struct patient{char firstname[20];char lastname[20];int id;double savingacct;int operationid;int chosendoc;};struct doctor{char firstname[20];char lastname[20];int id;double checkacctbal;int countopera;double clinicsal;double doc_charges;};struct clinic{char clinicname[20];char parentcomp[20];int operations[MAX_OPER];double docsalaries[MAX_DOCS];struct doctor *doc[MAX_DOCS];struct patient *pat[MAX_PATIENTS];};void large_recursive(FILE *notefile, struct clinic *xhosp);int main(void){FILE *file;int m;struct clinic hosp;struct patient *xpter;file = fopen("hw4.dat", "r");if(file == NULL){coutlastname, &(xhosp->doc[index]->id));coutfirstnamelastnameidRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.