Looking for any help with this program. Her are the specifications. It reads fro
ID: 3778178 • Letter: L
Question
Looking for any help with this program. Her are the specifications. It reads from a .txt file and outputs to a .txt file. Any help would be appreciated.
Charity Runs are a popular way for organizations to raise awareness and get fit at the same time. However, these events can be tough to organize. The Princess Half Marathon Weekend, for example, has as many as 40,000 runners raising money and awareness for the Children’s Miracle Network Hospitals. People can run both 5ks and 10ks and there’s even a children’s race.
Your program will log the number of teams and individual who are signed up for the different races, process the racing events to see who has the fastest times, and track the total amount of money raised by teams and individuals for charity.
Program Details
Individual Registration Details
There are a two registration windows: early registration and regular registration. Prices for registering early and regularly will be given. Each individual will have a unique number and must be processed separately to record their name, age, running event, and donations raised. The maximum number of runners for our program will be 10000.
Team Registration Details
Teams may be created and registered to sign up several participators at once. Teams may only sign up during early registration, have between 5 and 50 members, and must pay the team registration fee for every member on the team. Teams should be recorded with their name and number of members. Each member of the team still needs to be recorded with their name, age, running event, and donations raised. We can organize at most 200 teams.
Running Events Details
There will be three running events: a 5k race, a 10k race, and a marathon race. For each race, your program will receive the running time for each participant in the race. For the 5k and the 10k you should print the runner with the fastest time. For the marathon, your program will need to check times against the required qualifying times to see which runners qualify for more marathon races. These qualifying times vary by age group.
Total Donation Details
After all the races are run we want to recognize the participants who raised the most money for charity. Print the team that raised the most money for the event along with the amount raised. Then for each team, print the team member who raised the most money along with the amount raised. For the individuals, print the top individual who raised the most money along with the amount raised. Finally, print the total amount raised for the event. All donations and registration fees will be donated directly to charity.
Implementation Restrictions
You must use the following constants:
#define TEAMS 200
#define RUNNERS 10000
#define LENGTH 20
#define TEAMSIZE 50
You must use the following structures to store information:
struct person {
char name[LENGTH];
int number;
int age;
int event;
float money;
float time;
};
struct team {
char name[LENGTH];
int nummembers;
float money;
struct person members[TEAMSIZE];
};
It is not sufficient to simply have the structures in your program, you must use them store information and process operations for the program.
Though function prototypes will not be provided, it is expected that you follow good programming design and create several functions with well-specified tasks related to the solution of this problem. Make sure to pay very careful attention to parameter passing.
Input Specification
The first line of the file contains the following three values, separated by spaces:
Cost of early registration for individuals (in dollars), Cost of regular registration for individuals (in dollars), and the cost of team registration (in dollars). These will be positive real numbers to two decimal places.
The second line of the file will contain one positive integer representing the number of early individuals and teams who are registering. Every registration will start with either TEAM or INDV for a team registration or individual registration respectively.
Lines that begin with INDV will be followed by four values, separated by spaces:
The individual’s name, their age, their chosen running event, and the amount of donations they have raised. The first is a string, the second is a positive integer, the third is an integer from the set {5, 10, 42}, and the fourth is a positive real number.
Lines that begin with TEAM will be followed by two values, separated by spaces: the name of the team and the number of team members (k). This will be followed by k lines organized the same as the individual registration above.
After early registration completes, normal registration can begin. This will be represented by one positive integer (m) representing the number of regular registrations. All teams must use early registration. This will be followed by m lines each with four values. These are the same values that are present in individual registration: The team member’s name, their age, their chosen running event, and the amount of donations they have raised. The first is a string, the second is a positive integer, the third is an integer from the set {5, 10, 42}, and the fourth is a positive real number.
After registration, the running events can occur. Every registered participant will be listed with their number (assigned as part of registration) and the time it took them to run the race in minutes represented as a real number.
This will be followed by 10 lines of qualifying times based on age groups. They will be specified:
STARTINGAGE ENDINGAGE TIME
where starting age and ending age are integers, and the qualifying time is a real number representing minutes.
Output Specification
For an individual registering for an event print a line of the form:
X registered for the Y race! They have been assigned the number Z.
where X is their name and Y is the event they are registering for. Y is represented by an integer {5, 10, 42} in the input file. Replace it with “5k” for the first integer, “10k” for the second integer, and “marathon” for the third integer in this print statement. Z is their unique runner number. These numbers should start at 1 and count up to a max of 10000.
For a team registering print a line with one of the form:
X team registered for the event. They have Y members:
where X is the team name and Y is their number of members. Follow this with Y lines of the same form as the individuals: one for each member of the team.
For the 5k race and the 10k race, output a single line of the following form:
Xk race: Y had the fastest time with Z.Z minutes!
where X is either 5 or 10 respectively, Y represents the name of the fastest runner and Z represents their time.
For the marathon race, print out all the runners who times meet the qualifying times:
X qualified in the marathon run with a time of Y.Y minutes!
where X represents the name of the fastest runner and Y represents their time.
For the team that raised the most money, output a single line of the following form:
The X team raised the most money with a team donation of $Y.YY!
where X is the team name and Y is the amount they raised.
For each team, print out the person that raised the most with a single line of the following form:
X raised the most money on team Y with a donation of $Z.ZZ!
where X is the person’s name, Y is the team name, and Z is the amount they raised.
For the individual that raised the most money, output a single line of the following form:
X raised $Y.YY!
where X is the person’s name and Y is the amount they raised.
End with the total amount raised by the event:
The runners raised $X.XX for charity!
Each test file is labeled as raceXX.txt for input and raceXX.out for output. Out files can be opened in notepad and other unformatted text editors.
Here is an example of an input test file:
25.5 35.75 21
5
INDV Emily 30 5 10
INDV Karla 27 10 25.6
INDV Martin 45 5 33.75
INDV Lucas 23 42 100
INDV Hayley 34 42 27.43
7
George 50 10 90.3
Evelyn 47 5 15.4
Linus 55 10 22.8
Charlie 40 42 150.75
Lucy 24 10 14.89
Leah 42 5 23.45
Thomas 29 5 10.6
Here is an example of an output test file:
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
Need Some more time since it is lengthy question. I have pasted the code till I did.
#include<stdio.h>
#define TEAMS 200
#define RUNNERS 10000
#define LENGTH 20
#define TEAMSIZE 50
struct person{
char name[LENGTH];
int number;
int age;
int event;
float money;
float time;
};
struct team{
char name[LENGTH];
int nummembers;
float money;
struct person members[TEAMSIZE];
};
struct FEE
{
float early;
float regular;
float team;
}fee;
int total_runners;
struct individual_list
{
struct person *data;
struct individual_list *next;
};
struct individual_list *ind_early_head = NULL;
struct individual_list *ind_reg_head = NULL;
struct team_list
{
struct team *data;
struct team_list *next;
};
struct common_list
{
struct person *data;
int group;//0 for early_ind,1 for reg_ind, 2 for team
struct common_list *next;
};
struct common_list *common_head = NULL;
struct team_list *team_head = NULL;
FILE *input;
void add_individual_list(struct person *temp,struct person **head)
{
struct individual_list *temp1 = malloc(sizeof(struct individual_list));
temp1 = temp;
temp1 -> next = *head;
*head = temp1;
struct common_list *common_temp = malloc(sizeof(struct common_list));
common_temp = temp;
common_temp = temp;
common_temp -> next = common_head;
common_head = common_temp;
return;
}
void add_team_list(struct team *temp)
{
struct team_list *temp1 = malloc(sizeof(struct team_list));
temp1 = temp;
temp1 -> next = team_head;
team_head = temp1;
return;
}
int parse_fee(void)
{
input = fopen(input_file,"r");
if(!input)
{
return -1;
}
fscanf(input,"%f %f %f",&fee.early,&fee.regular,&fee.team);
return 0;
}
void parse_registration(void)
{
int early_count,i,reg_count;
char string[5];
fscanf(input,"%d",&early_count);
int unique_number = 1;
for(i=1;i<=early_count;i++)
{
fscanf(input,"%s",string);
if(!strcmp(string,"INDV"))
{
struct person *temp = malloc(sizeof(struct person));
fscanf("%s %d %d %f",temp->name,&temp->age,&temp->event,&temp->money);
temp -> number = unique_number;
unique_number++;
add_individual_list(temp,&ind_early_head);
}
else
{
struct team *temp = malloc(sizeof(struct team));
fscanf("%s %d",temp->name,&temp->nummembers);
int i;
for(i=1;i<=temp->nummembers;i++)
{
fscanf("%s %d %d %f",temp->members[i].name,&temp->members[i].age,&temp->members[i].event,&temp->members[i].money);
temp->members[i].number = unique_number;
unique_number++;
add_team_list(temp);
}
}
}
reg_count = fscanf(input,"%d",®_count);
for(i=1;i<=reg_count;i++)
{
struct person *temp = malloc(sizeof(struct person));
fscanf("%s %d %d %f",temp->name,&temp->age,&temp->event,&temp->money);
temp -> number = unique_number;
unique_number ++;
add_individual_list(temp,&ind_reg_head);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.