
QuestionAnswered step-by-stepYou and your friends have decided to get in shape by runningswimming and biking. To encourage everyone to participate, you have decided to track how far everybody runs bikes or swims. All distances will be recorded in kilometres. The information on how far everyone exercises is stored in a simple text file as shown below.Your program should read this text file and then be able to present the information in various ways. (The code to read the file is provided for you below) You should be able to list the information as:List of all activities performed by each of the group members along with the date on which the activity was performed. Rather than displaying the numeric date, you will display the day and month as text. To convert any date as a numeric day month and year into the actual day of week we can use Zeller’s congruence. The code for Zeller’s congruence is included below. This code works on a date structure that contains the fields for numeric month, day, and year.List the total distance for any single sport for each of the participants sorted from the highest to the lowest.List the top distance traveled for any single sport where the top distance of each participant is sorted from highest to lowest.The following shows the content of the data file the program will read when it starts. The fields include:The name of the participant,The activityThe year, month, and day of the activity,The distance travelled.Billy Bob~run~2021~04~17~4.2Jimmy Joe~swim~2021~04~17~0.45Bobby Sue~bike~2021~04~17~18.6Sue Ellen~run~2021~04~18~6.1Billy Bob~run~2021~04~18~3.4Billy Bob~bike~2021~04~18~34.8Jimmy Joe~swim~2021~04~18~.8Bobby Sue~bike~2021~04~18~28.0Bobby Sue~bike~2021~04~18~21.9Billy Bob~run~2021~04~19~1.0Billy Bob~bike~2021~04~19~55.2Bobby Sue~bike~2021~04~19~22.8Jimmy Joe~swim~2021~04~20~1.0Sue Ellen~swim~2021~04~18~1.2?he following shows the output from an example running of the program. User input is highlighted in yellow.Read 4 participants?elect one of the following options:0 – Exit1 – list all participants and events2 – list total run distances3 – list total swim distances4 – list total bike distances5 – list best run distances6 – list best swim distances7 – list best bike distances1Billy Bob———————————————-?un Sat Apr 17?4.2?un Sun Apr 18?3.4?ike Sun Apr 18?4.8?un Mon Apr 19?1.0?ike Mon Apr 19?5.2?immy Joe———————————————-?wim Sat Apr 17?0.5?wim Sun Apr 18?0.8?wim Tue Apr 20?1.0?obby Sue———————————————-?ike Sat Apr 17?8.6?ike Sun Apr 18?8.0?ike Sun Apr 18?1.9?ike Mon Apr 19?2.8?ue Ellen———————————————-?un Sun Apr 18?6.1?wim Sun Apr 18?1.2?elect one of the following options:0 – Exit1 – list all participants and events2 – list total run distances3 – list total swim distances4 – list total bike distances5 – list best run distances6 – list best swim distances7 – list best bike distances2??*** TOTAL RUNS ***???Billy Bob?8.6???Sue Ellen?6.1???Jimmy Joe?0.0???Bobby Sue?0.0?elect one of the following options:0 – Exit1 – list all participants and events2 – list total run distances3 – list total swim distances4 – list total bike distances5 – list best run distances6 – list best swim distances7 – list best bike distances3??*** TOTAL SWIMS ***???Jimmy Joe?2.3???Sue Ellen?1.2???Billy Bob?0.0???Bobby Sue?0.0?elect one of the following options:0 – Exit1 – list all participants and events2 – list total run distances3 – list total swim distances4 – list total bike distances5 – list best run distances6 – list best swim distances7 – list best bike distances4??*** TOTAL BIKES ***???Bobby Sue?91.3???Billy Bob?90.0???Jimmy Joe?0.0???Sue Ellen?0.0?elect one of the following options:0 – Exit1 – list all participants and events2 – list total run distances3 – list total swim distances4 – list total bike distances5 – list best run distances6 – list best swim distances7 – list best bike distances5??*** TOP RUNS ***???Sue Ellen?6.1???Billy Bob?4.2???Jimmy Joe?0.0???Bobby Sue?0.0?elect one of the following options:0 – Exit1 – list all participants and events2 – list total run distances3 – list total swim distances4 – list total bike distances5 – list best run distances6 – list best swim distances7 – list best bike distances6??*** TOP SWIMS ***???Sue Ellen?1.2???Billy Bob?0.0???Jimmy Joe?1.0???Bobby Sue?0.0?elect one of the following options:0 – Exit1 – list all participants and events2 – list total run distances3 – list total swim distances4 – list total bike distances5 – list best run distances6 – list best swim distances7 – list best bike distances7??*** TOP BIKES ***???Billy Bob?55.2???Bobby Sue?28.0???Jimmy Joe?0.0???Sue Ellen?0.0?elect one of the following options:0 – Exit1 – list all participants and events2 – list total run distances3 – list total swim distances4 – list total bike distances5 – list best run distances6 – list best swim distances7 – list best bike distances8Enter a number between 0 and 7: 0Goodbye?eller’s congruence is an algorithm that takes a date specified as a numeric year, month, and day and converts this to a day of the week. It assumes that you specify that January is month one, and that the day is the day in the month where the first day of the month is 1. It returns the numeric day of the week where zero is Saturday, one is Sunday, etc. The code for this algorithm is listed next and you can use this in your final solution. It expects a pointer to a date structure to be passed to it that contains the numeric fields for the year, the month, and the day.int zeller(const struct Date* date){??nt month = date->month;??nt year = date->year;??f (date->month < 3)?????year–;???month += 12;????nt yr = year % 100;??nt century = year / 100;??nt result = date->day;??esult += 13 * (month + 1) / 5;??esult += yr;??esult += yr / 4;??esult += century / 4;??esult -= 2 * century;??esult = result % 7;??eturn result;}The following code reads the file with the data on the participants and stores it in an array of type Participant. You are responsible for creating a structure that can be used with the code below. You should read the code below very carefully so that you understand how to build the Participant structure and the other structures it contains. The array of activity names is passed to the readActivityFile function to allow the function to translate the textual activity names to a number corresponding to the index of the activity name in the array. This will allow for more efficient storage of the activity names in memory. Your code is responsible for opening and closing the file that this function will read. This function also relies on other function, which you are responsible for writing.int readActivityFile(FILE* fp, struct Participant participants[],const char activNames[][MAX_ACTIVITY_NAME_LEN + 1]){??nt count = 0, ch, addPosn, actPosn;??har activity[16];??har name[MAX_NAME_LEN + 1];??nt year=0, month=0, day=0;??ouble dist=0.0;??while (!feof(fp))?????fscanf(fp, “%[^~]s%*c”, name);???ch = fgetc(fp);???fscanf(fp, “%[^~]s%*c”, activity);???ch = fgetc(fp);???fscanf(fp, “%d”, &year);???ch = fgetc(fp);???fscanf(fp, “%d”, &month);???ch = fgetc(fp);???fscanf(fp, “%d”, &day);???ch = fgetc(fp);???fscanf(fp, “%lf”, &dist);???ch = fgetc(fp);???addPosn = findParticipant(participants, count, name);???if (addPosn < 0)???{?????ddPosn = count;?????ount++;?????articipants[addPosn].numActivities = 0;?????trcpy(participants[addPosn].name, name);???}????ctPosn = participants[addPosn].numActivities;???participants[addPosn].activities[actPosn].activityType =????findString(activNames, NUM_ACTIVITY_NAMES, activity);???participants[addPosn].activities[actPosn].date.year = year;???participants[addPosn].activities[actPosn].date.month = month;???participants[addPosn].activities[actPosn].date.day = day;???participants[addPosn].activities[actPosn].distance = dist;???participants[addPosn].numActivities++;????h = fgetc(fp);???if (!feof(fp)) ungetc(ch, fp);????eturn count;}Engineering & TechnologyComputer ScienceIPC 144Share Question
Get a plagiarism-free order today we guarantee confidentiality and a professional paper and we will meet the deadline.