Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ENGG1003 Introduction to Procedural Programming Programming Assignment 2 v.2 PROBLEM STATEMENT: The Soccer World Cup is one of the main sporting events in the world.

ENGG1003 Introduction to Procedural Programming Programming Assignment 2 v.2

PROBLEM STATEMENT: The Soccer World Cup is one of the main sporting events in the world. The game is called Soccer in Australia because we play 4 different types of football; however, most of the world simply refers to it as Football. The International Federation of Associated Football FIFA (Federation Internationale de Football Association) runs this competition every four years, and this year it will be in Russia. Unfortunately, FIFA has lost all programs that report countries positions and scores. Currently, a company has been hired to develop a completely new application, but it wont be ready until the knockout stage of the competition. Therefore, there is a need to report on the groups and team positions including everyday results, so news can be reported. Thus, the program needs to be rewritten in its simplest possible form to supply this information. The program will just use simple text files for input. You will need to write a program that allows FIFA to feed in simple text files of group teams and soccer matches results and produce lists that are ordered per group, alphabetically, as well as, in country performance order.

BACKGROUND: The Soccer World Cup features 32 national teams competing over the course of a month in the host nation. There are two stages: the group stage followed by the knockout stage. In the group stage, teams compete within eight groups of four teams each. Each group plays a round-robin tournament, in which each team is scheduled for three matches against other teams in the same group. This means that a total of six matches are played within a group. The top two teams from each group advance to the knockout stage. Points are used to rank the teams within a group. Three points are awarded for a win, one for a draw and none for a loss. The soccer national teams within the group are ranked, initially, according to this given points; however, in some cases there could be ties. When there is a tied position, this one is solved as per the following criteria:

1. Team with the greatest goal difference in all group matches gets the position.

2. Team with the greatest combined number of goals scored in all group matches gets the position. .

The knockout stage is a single-elimination tournament in which teams play each other in one-off matches, with extra time and penalty shootouts used to decide the winner if necessary. It begins with the round of 16 (or the second round) in which the winner of each group plays against the runner-up of another group. This is followed by the quarterfinals, the semi-finals, the third-place match (contested by the losing semi-finalists), and the final. In order to properly report the results needed, you will need to hold data for each country comprising: Team Name (a character array large enough to hold the longest name say 16 characters), Group, Games Played, Games Won, Games Drawn, Games Lost, Goals For, Goals Against, Points. The above data is best stored in a C-struct for each team. If you want, you can also create another C-struct for groups, but definitely, it will be best to work with an array of these struct(s) being the complete data held for the World Cup. For the 32 Soccer World Cup teams, we will use shortened team names, so there wont be any space between words. Results for a World Cup game are reported giving the names of the teams and the number of goals scored, e.g. TeamA 3 TeamB 2. Note that this means that TeamA has won the game 3-2, while TeamB has lost the game 2-3. If the number of goals for each team is equal, then the game result is a draw, e.g. TeamC 1 TeamD 1 would be a 1-1 draw for both teams.

TASKS: Your program will read two data files, set up in the same folder as was done for the first assignment. These data files are called team.dat and match.dat. You program should have the following steps:

1. Read the national football team names and the group they belong to from the first data file and store them (wherever your program design says it is best to do so). There will be 32 names, and each group contain 4 teams. You may then close the first file. You may assume that this first data file does not contain any errors at all. The file contains the team names ordered per group.

2. Read the second data file, reading and processing one data set at a time, stopping at end-offile. The second data file will contain data for all the games played during the current time period. Each data set in this file will consist of a result for an individual game, and will consist of 2 team names, each followed by a number of goals (that is, each data set will have the form: first_team first_score second_team second_score). It will also be possible for this file to be empty.

3. For each data set, check for data consistency. If any data item is negative the data set is invalid. Any invalid data set is reported with an error message and ignored. E.g. Colombia 3 Poland -1 data is invalid

4. For each data set, find the correct teams name in your data structure. If the teams name cannot be found, including matching exactly by case, then the data is also invalid, whereupon it is reported as such, and then ignored. E.g. Columbia 2 Japan 1 name not found in team list australia 1 France 1 name not found in team list

5. Once the data set is valid, for each match, you will need to record the result for each team (that is the win for one team and the loss for the other, or a draw for both of them), and the goals counters. This will involve updating the data values for the respective teams. You will need to search for the names of the teams and record the respective result for each team.

6. Produce a by performance by group decreasing ordered list of the teams as per required table of reporting (below). Use an output format that will left-justify the name. This should be reasonably simple since the team names were originally input in by group order.

7. Produce (sort) an alphabetically ordered list of the teams and their performances as per required table of reporting (below). Use an output format that will left-justify the name.

8. Produce (sort) a list of teams by decreasing order of team performance as per required table of reporting (below). This will be a challenging task think carefully about how you will compare the ranking of any two teams this becomes the basis for sorting. Observation: While it is possible to complete this assignment using a number of parallel arrays, your design will be better and easier to work with, if you define your own structure(s) type (it is best to use a naming convention of structname_t), and then have a single array of these objects. Your design will also benefit from having a number of functions. A solution that does not have well designed functions to perform major tasks will be marked down significantly.

OUTPUT: Use output formats that will allow normal data to be output in columns. Use headings as appropriate to display the data as a table along the following guidelines (the actual numbers used here are fictitious): FIFA World Cup Russia 2018 Program Developed by Cesar Sanin Student Number c12345678 Computer Lab Monday 1 pm - 4 pm Opening files. Processing Colombia 3 Poland -1 data is invalid Columbia 2 Japan 1 name not found in team list australia 1 France 1 name not found in team list Valid data sets 45 Closing files. Name should be left-justified as stated above, all numerical columns are a maximum of 3 digit integers, but have more characters wide (as per the column label plus spaces).

DATASETS: Input file team.dat is provided in Blackboard. It includes the 32 football teams organized by their groups. Note that none of the team names contain spaces (this will make string input easier). These will appear correctly in the first data file (team.dat). The only errors possible in the first input file will be as follows: 1. The File is non-existent. Input file match.dat is provided in Blackboard with some data samples. Your program will be graded on a number of data sets for the second data file. While the file containing the team list will always have 32 names, the second data file may have any number of complete data sets. As games are played, extra data can then be easily added to the end of the match.dat file. The only errors possible in the second input file will be as follows:

2. The File is non-existent or empty.

3. A team name may be misspelt (i.e. different to the name given in the first data file). This will result in your array/struct search not finding one of the team names given in the data set.

4. The number of goals scored by a team may be given as negative. In each case, you print out the data values read in with an appropriate warning message, and ignore the data values for that game (that is you don't update any team, even if one of the team names is correct), and you continue on to the next data set.

OTHER PROGRAMMING REQUIREMENTS No global variables are allowed (struct definitions are not variables). Your program needs to display all information such that is easy to read and as per the sample output presented. Your code also must be very well commented and have a head of code for the programs and for the functions. You should use all methods you create. You can create any functions/methods that you considered necessary. Sorting is also commonly used in computing. You may sort the array using the Bubble Sort algorithm, shown here: void BubbleSort (int A[], const int arraySize) { int i, j; for(i = 0; i < arraySize; i++) for(j = 0; j < arraySize-1; j++) if(abs(A[j]) > abs(A[j+1])) swap(A+j, A+j+1); } Note that this algorithm sorts the array A in place. Note also that it sorts by the absolute values of the elements of A. Finally, note that it uses array arithmetic to pass pointers to the swap function. The swap function is void swap (int *a, int *b) { int temp = *a; *a = *b; *b = temp; }

team.dat

Russia A

SaudiArabia A

Egypt A

Uruguay A

Portugal B

Spain B

Morocco B

Iran B

France C

Australia C

Peru C

Denmark C

Argentina D

Iceland D

Croatia D

Nigeria D

Brazil E

Switzerland E

CostaRica E

Serbia E

Germany F

Mexico F

Sweden F

SouthKorea F

Belgium G

Panama G

Tunisia G

England G

Poland H

Senegal H

Colombia H

Japan H

match.dat

Russia 2 SaudiArabia 1

Morocco 1 Iran 1

France 2 Australia 0

Argentina -2 Iceland 0

CostaRica 1 Serbia 1

Germany 1 Mexico 0

Belgium 2 Panama 2

Colombia 2 Japan 1

Egypt 1 Uruguay 2

Portugal 1 Spain 1

Peru 2 Denmark 2

croatia 0 Nigeria 0

Brazil 3 Switzerland 1

Sweden 1 SouthKorea -2

Tunisia 1 England 3

Poland 1 Senegal 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2023 Workshops 34th International Conference Dexa 2023 Penang Malaysia August 28 30 2023 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Maqbool Khan

1st Edition

ISBN: 303139688X, 978-3031396885

More Books

Students also viewed these Databases questions

Question

understand the meaning of the terms discipline and grievance

Answered: 1 week ago