[solved]-Coded C Please Make Sure Code Work Send Makefile Required Make Program Work Worldcupcsv C Q38993460
To be coded in C. Please make sure the code is workbefore you send it. Makefile is required to make this programwork.



Worldcup.csv:

country.c :
/* country.c */
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include “country.h”
/**********************************************************
* search_by_country: Prompts the user to enter a country *
* name, then prints the record of *
* that country if it exists. *
**********************************************************/
void search_by_country(struct country countries[])
{
/********* ADD YOUR CODE HERE ******/
}
/**********************************************************
* search_by_group: Prompts the user to enter a group, *
* then prints the records of that group *
* if it exists. *
**********************************************************/
void search_by_group(struct country countries[])
{
/********* ADD YOUR CODE HERE ******/
}
/**********************************************************
* search_by_points: Prompts the user to enter a point, *
* then prints the records having *
* that many points, if it exists. *
**********************************************************/
void search_by_points(struct country countries[])
{
/********* ADD YOUR CODE HERE ******/
}
/**********************************************************
* print_sorted_by_goals: Sorts the records in acending *
* order according to goal scored *
* and prints them *
**********************************************************/
void print_sorted_by_goals(struct country countries[])
{
/********* ADD YOUR CODE HERE ******/
// THIS IS FOR EXTRA CREDIT
}
void selection_sort(struct country countries[], int n)
{
/********* ADD YOUR CODE HERE ******/
// THIS IS FOR EXTRA CREDIT
}
int read_line(char str[], int n)
{
int ch, i = 0;
while (isspace(ch = getchar()))
;
while (ch != ‘n’ && ch != EOF) {
if (i < n)
str[i++] = ch;
ch = getchar();
}
str[i] = ”;
return i;
}
Worldcup.c :
/*********************************************************
* worldcup.c: *
* Program to read in country records from worldcup.csv *
* and search records by country, group, or points. *
* *
* *
* compile: gcc -Wall -o worldcup worldcup.c country.c *
* usage: ./worldcup <input filename> *
* example: ./worldcup worldcup.csv *
*********************************************************/
// Add all #include directives here
int main(int argc, char *argv[])
{
/********* ADD YOUR CODE HERE ******/
// You need to read in the CSV records into
// an array of structure “countries”
/*********************************************/
// Uncomment the following line if you have done extracredit
// print_sorted_by_goals(countries); // THIS IS FOR EXTRACREDIT
for (;;) {
printf(“Search by country: cn”);
printf(“Search by group: gn”);
printf(“Search by points: pn”);
printf(“Quit: qn”);
printf(“Enter operation code: “);
// Scan and process operation code
}
return 0;
}
The 2018 FIFA World Cup tournament was comprised of 32 competing nations, divided into 8 groups, A through H, with each group having 4 countries. In the group stage, each country plays exactly 3 matches. A CSV file provided for this project, worldcup.csv’, contains 32 records, one for each country. Each record has 4 fields – the name of the country, the group the country belongs to, goals scored, and points earned. In this project, your will be reading in the CSV file into an array of structure and implementing functions that will search this array based on the country name, group, or points earned (input by user). For your convenience, I have provided two base files (country.c and worldcup.c) to start with, study them and complete this project by 1) creating the header file and 2) adding your code to these base files. worldcup.c: This file has the main function. Make an array of structure country here. Complete the main function by reading in the records from the CSV file (name is passed from command line) into this array. Add any other code necessary. country.c: This file contains the function definitions that you need to complete. There are three functions, search_by_country, search_by_group, and search_by_points that you need to complete. In each of these function, prompt the user to enter country/group/points and print out the records that match. If there is no match, you can simply not print anything. See example execution to get an idea. country.h: Create this file from the information in country.c. It should contain the prototypes of functions that are defined in country.c. The structure country should also be defined to store all the information about a country. Finally, define two global variables: NAME_LENGTH (set to 35) and NUM_COUNTRY (set to 32) that you can reference in country.c. IMPORTANT: 1. Take input filename (argv[1]) form the command line. 2. Do not modify the lines (source code) that are provided in the base files, only add to the files. 3. You need to also have a makefile (for easy compilation) to create an executable program called worldcup along with the three source/header file. 4. Submit a zip file containing country.h, country.c, worldcup.c, and Makefile 5. Your project will be graded in a similar fashion as shown below in example executions. Example executions: (Assume your current directory has country.h, country.c, worldcup.c, worldcup.csv, and Makefile. User inputs are in bold and underlined.) Source: 2018 FIFA WORLD CUP RUSSIA – https://www.fifa.com/worldcup/groups/ $ make $ ./worldcup worldcup.csv Search by country: C Search by group: g Search by points: P Quit: Enter operation code: c Enter country name: Saudi Arabia Country Group Goals Points Saudi Arabia A 2 Search by country: C Search by group: g Search by points: p Quit: Enter operation code: 9 Enter group: D Country Group Goals Points Argentina D 3 Croatia Iceland Nigeria WNW WP Search by country: C Search by group: g Search by points: p Quit: Enter operation code: P Enter points: 9 Country Group Goals Points Belgium G99 Croatia D7 9 Uruguay A 5 9 Search by country: C Search by group: g Search by points: p Quit: Enter operation code: C Enter country name: China Country Group Goals Points 9 Search by country: C Search by group: g Search by points: p Quit: Enter operation code: g Enter group: F Country Group Goals Points Germany Mexico South Korea Sweden F 5 um w WND wow Search by country: C Search by group: g Search by points: P Quit: Enter operation code: 9 EXTRA CREDIT (10 points) Complete the function print sorted by goals and selection sort in country.c. The first function should call the second function to sort the 32 records according to goals scored in ascending order and then print out all the 32 sorted records. You may use similar logic as done previously in class for selection_sort. If you do this part, uncomment Line 27 in worldcup.c which calls the print_sorted_by_goals function. You do not submit any extra file if you do this extra credit. This should print out something as shown below. Group Goals Points Country Australia Panama 0 600 NN 6 England Belgium G G Goals Points NW +oVA с Country Group Argentina D Australia C Belgium G Brazil E Colombia H Costa Rica E Croatia D Denmark C Egypt А England France Germany F Iceland Iran Japan H Mexico Morocco B Nigeria D Panama G Peru C Poland H Portugal B Russia A Saudi Arab A Senegal H Serbia E South Kore F Spain B Sweden F Switzerlanc E Tunisia G Uruguay A OMILOO a unaooWNAN OOONNNWNWANNN WOONNN owoooww wow Wow – AAw voo Show transcribed image text The 2018 FIFA World Cup tournament was comprised of 32 competing nations, divided into 8 groups, A through H, with each group having 4 countries. In the group stage, each country plays exactly 3 matches. A CSV file provided for this project, worldcup.csv’, contains 32 records, one for each country. Each record has 4 fields – the name of the country, the group the country belongs to, goals scored, and points earned. In this project, your will be reading in the CSV file into an array of structure and implementing functions that will search this array based on the country name, group, or points earned (input by user). For your convenience, I have provided two base files (country.c and worldcup.c) to start with, study them and complete this project by 1) creating the header file and 2) adding your code to these base files. worldcup.c: This file has the main function. Make an array of structure country here. Complete the main function by reading in the records from the CSV file (name is passed from command line) into this array. Add any other code necessary. country.c: This file contains the function definitions that you need to complete. There are three functions, search_by_country, search_by_group, and search_by_points that you need to complete. In each of these function, prompt the user to enter country/group/points and print out the records that match. If there is no match, you can simply not print anything. See example execution to get an idea. country.h: Create this file from the information in country.c. It should contain the prototypes of functions that are defined in country.c. The structure country should also be defined to store all the information about a country. Finally, define two global variables: NAME_LENGTH (set to 35) and NUM_COUNTRY (set to 32) that you can reference in country.c. IMPORTANT: 1. Take input filename (argv[1]) form the command line. 2. Do not modify the lines (source code) that are provided in the base files, only add to the files. 3. You need to also have a makefile (for easy compilation) to create an executable program called worldcup along with the three source/header file. 4. Submit a zip file containing country.h, country.c, worldcup.c, and Makefile 5. Your project will be graded in a similar fashion as shown below in example executions. Example executions: (Assume your current directory has country.h, country.c, worldcup.c, worldcup.csv, and Makefile. User inputs are in bold and underlined.) Source: 2018 FIFA WORLD CUP RUSSIA – https://www.fifa.com/worldcup/groups/
$ make $ ./worldcup worldcup.csv Search by country: C Search by group: g Search by points: P Quit: Enter operation code: c Enter country name: Saudi Arabia Country Group Goals Points Saudi Arabia A 2 Search by country: C Search by group: g Search by points: p Quit: Enter operation code: 9 Enter group: D Country Group Goals Points Argentina D 3 Croatia Iceland Nigeria WNW WP Search by country: C Search by group: g Search by points: p Quit: Enter operation code: P Enter points: 9 Country Group Goals Points Belgium G99 Croatia D7 9 Uruguay A 5 9 Search by country: C Search by group: g Search by points: p Quit: Enter operation code: C Enter country name: China Country Group Goals Points 9 Search by country: C Search by group: g
Search by points: p Quit: Enter operation code: g Enter group: F Country Group Goals Points Germany Mexico South Korea Sweden F 5 um w WND wow Search by country: C Search by group: g Search by points: P Quit: Enter operation code: 9 EXTRA CREDIT (10 points) Complete the function print sorted by goals and selection sort in country.c. The first function should call the second function to sort the 32 records according to goals scored in ascending order and then print out all the 32 sorted records. You may use similar logic as done previously in class for selection_sort. If you do this part, uncomment Line 27 in worldcup.c which calls the print_sorted_by_goals function. You do not submit any extra file if you do this extra credit. This should print out something as shown below. Group Goals Points Country Australia Panama 0 600 NN 6 England Belgium G G
Goals Points NW +oVA с Country Group Argentina D Australia C Belgium G Brazil E Colombia H Costa Rica E Croatia D Denmark C Egypt А England France Germany F Iceland Iran Japan H Mexico Morocco B Nigeria D Panama G Peru C Poland H Portugal B Russia A Saudi Arab A Senegal H Serbia E South Kore F Spain B Sweden F Switzerlanc E Tunisia G Uruguay A OMILOO a unaooWNAN OOONNNWNWANNN WOONNN owoooww wow Wow – AAw voo
Expert Answer
Answer to To be coded in C. Please make sure the code is work before you send it. Makefile is required to make this program work. … . . .
OR

