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

I am trying to get my code to work. If you could fix my code and allow the input

ID: 3571409 • Letter: I

Question

I am trying to get my code to work. If you could fix my code and allow the input of the code to match the output I gave, I would greatly appreciate it.

MY CURRENT CODE:

#include
#include

#define TEAMS 200
#define RUNNERS 10000
#define LENGTH 20
#define TEAMSIZE 50
//creating person structure
struct person {
char type[4];
char name[LENGTH];
int number;
int age;
int event;
float money;
float time;
};
//creatind team structure
struct team {
char name[LENGTH];
int numbers;
float money;
struct person *members;
};

//declaring team and person structures
struct person persons[1000];
struct team teams[200];
int per_size=0;
int t_size=0,i=0;


//regiserting a person
void registerPerson(struct person p){
if(RUNNERS!=per_size){
p.number=per_size;
(persons)[per_size]=p;
per_size=per_size+1;
printf(" %s register for the %dk race.They have been assigned with %d number",p.name,p.event,p.number);
}
else{
printf("maximum runners reached");
return;
}
}
//register a team
void registerTeam(struct team t){
if(t_size>=5 && t_size<=TEAMSIZE){
teams[t_size]=t;
t_size=t_size+1;
printf(" The %s team register for the event.THey have %d members",t.name,t.numbers);
}
else{
printf("maximum team reached");
return;
}
}
void race5k_calc(){
int i=0;
struct person p;
//calculate for individual persons
for(i=0;i {
p=persons[i];
//checking whether person event is 5k run and finding the winner
if((persons[i].event==5) && (persons[i+1].event==5)){
if((persons[i].time==persons[i+1].time))
{
p=persons[i];
}
else if((persons[i].time {
p=persons[i];
}
else if((persons[i].time>persons[i+1].time) )
{
p=persons[i+1];
}
}
}
printf(" 5K RACE: %s has the fastest time with %f minutes",p.name,p.time);
}
void race10k_calc(){
int i=0;
struct person p;
//checking person event is 10k run and finding the winner
for(i=0;i {
p=persons[i];
if((persons[i].event==10 )&&(persons[i+1].event==10)){
if((persons[i].time==persons[i+1].time))
{
p=persons[i];
}
else if((persons[i].time {
p=persons[i];
}
else if((persons[i].time>persons[i+1].time) )
{
p=persons[i+1];
}
}
}
printf(" 10K RACE: %s has the fastest time with %f minutes",p.name,p.time);
}
void race_marathon_calc(){
int i=0;
int hrs,mts,secs;
struct person p;
//checking persons event is marathon and finding winner
for(i=0;i {
p=persons[i];
if((persons[i].event==42 )&&(persons[i+1].event==42)){
if((persons[i].time==persons[i+1].time))
{
p=persons[i+1];
}
else if((persons[i].time {
p=persons[i];
}
else if((persons[i].time>persons[i+1].time) )
{
p=persons[i+1];
}
}
}
printf("marathon RACE: %s has the fastest time with %f minutes",p.name,p.time);
}
//calculating the donation
void donation_calc(){
float amt=0,t_amt=0,max_amt=0;
struct person p,*members;
struct team t;
int i=0,j=0,l;
for(i=0;i t=teams[i];
members=t.members;
l=sizeof(members)/sizeof(*members);
for(j=0;j if(members[j].money>members[j].money){
max_amt=members[j].money;
p=members[j];
}
printf(" %s raised the mostmoney on the %s team with $%f amount",p.name,max_amt);
t_amt=t_amt+members[j].money;
printf(" The %s team raised the most money $%f ",t.name,t_amt);
}

}
amt=0;
for(i=0;i amt=amt+persons[i].money;
printf(" The runners raised $%f for charity",amt);
}

int main(){
FILE *fp;
char ch;
int i;
struct person p,*members;
struct team t;
char filename[20];
printf(" enter file's name :");
scanf("%s", filename);
// opening file for reading
fp = fopen(filename, "r");
//checking whether file is empty
if (fp == NULL) {
perror("Error opening file");
return(-1);
}

//getting information
while(feof(fp)!=1){
ch=fgetc(fp);
if(ch=='I'){
fread(&p, sizeof(p), 1, fp);
registerPerson(p);
printf(" person details %s",p.name," %d",p.age," %d",p.event," %f",p.money);
}
else if(ch=='T'){
fread(&t, sizeof(p), 1, fp);
registerTeam(t);
members= malloc(t.numbers*sizeof(&p));
for(i=0;i fread(&p, sizeof(p), 1, fp);
members[i]=p;
printf(" in team person details %s",p.name," %d",p.age," %d",p.event," %f",p.money);
registerPerson(p);
}
t.members=members;
}

race5k_calc(); //calling race 5k calucation
race10k_calc();//calling race 10k calculation
race_marathon_calc();//calling marathon race
donation_calc();//donation calculation.

}
fclose(fp);
return(0);
};

POSSIBLE INPUT

25.5 35.75 215INDV Emily 30 5 10INDV Karla 27 10 25.6INDV Martin 45 5 33.75INDV Lucas 23 42 100INDV Hayley 34 42 27.437George 50 10 90.3Evelyn 47 5 15.4Linus 55 10 22.8Charlie 40 42 150.75Lucy 24 10 14.89Leah 42 5 23.45Thomas 29 5 10.6

CORRESPONDING OUTPUT

Emily registered for the 5k race! They have been assigned the number 1.
Karla registered for the 10k race! They have been assigned the number 2.
Martin registered for the 5k race! They have been assigned the number 3.
Lucas registered for the marathon race! They have been assigned the number 4.
Hayley registered for the marathon race! They have been assigned the number 5.
George registered for the 10k race! They have been assigned the number 6.
Evelyn registered for the 5k race! They have been assigned the number 7.
Linus registered for the 10k race! They have been assigned the number 8.
Charlie registered for the marathon race! They have been assigned the number 9.
Lucy registered for the 10k race! They have been assigned the number 10.
Leah registered for the 5k race! They have been assigned the number 11.
Thomas registered for the 5k race! They have been assigned the number 12.

Explanation / Answer

What error are you getting? please send me the screenshot of the error & also send the input file. I will post the answer here.
gauravsaini15@outlook.com

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote