IPC
IPC 144
The Committee on the Status of Endangered Wildlife in Canada (COSEWIC) service manages data for species at risk (SAR). Ten years of reporting data is stored in a file (partially shown below - there a
...
IPC
IPC 144
The Committee on the Status of Endangered Wildlife in Canada (COSEWIC) service manages data for species at risk (SAR). Ten years of reporting data is stored in a file (partially shown below - there are 6,500 records in total) and a program is needed to help users summarize the contents of the file in various ways.
Code the program (create the necessary modules, functions, macro's, logic, etc.) that will produce correct data summaries and formatted output similar to that shown in the provided sample output text file attached to this question.
You MUST use the provided main.c file attached to this question and you are not allowed to make any changes to it. This means at minimum, you will have to create the necessary cosewic.h header file module where the FileData structure must be defined, including the two mandatory function prototypes: loadData and mainLogic.
The sample output demonstrates most of the functionality but your solution must implement all logic (example: report #4 has many possible combinations of province and taxon - your results must report the data accurately).
Data File: data.txt
Sample Output: sample-output.txt
Starter Source Code: main.c
Main Source Code File
(Download and use the provided source file "main.c" attached to this question)
// IPC144 2022 Summer Final Assessment Coding Project
// --------------------------------------------------
// Project idea is based on COSEWIC reports for SAR
//
// COSEWIC: Committee on the Status of Endangered Wildlife in Canada
// SAR: Species At Risk
//
// Source: https://bit.ly/3AEgab9
//
// Note: The data used for this assignment has been fictionalized with invalid counts
#define _CRT_SECURE_NO_WARNINGS
#include
#include "cosewic.h"
#define DATA_FILE "data.csv"
#define MAX_RECORDS 6500
int main(void)
{
int records;
struct FileData data[MAX_RECORDS] = { {0} };
printf("Loading data from file: %sn", DATA_FILE);
records = loadData(DATA_FILE, data, MAX_RECORDS);
printf("%d data records read from file...nn", records);
if (records > 0)
{
// Entry point to application logic
mainLogic(data, records);
}
else
{
printf("Ooooops there seems to have been an error loading data!n");
}
return 0;
}
Sample Data File (first 12 of 6,500 records)
(Download and use the provided data file attached "data.txt" to this question)
YEAR,TAXON,STATUS,COUNT,PROVINCE
2012,Lichens,THREATENED,3,BC
2019,Arthropods,EXTINCT,21,ON
2016,Fishes,THREATENED,49,NT
2018,Arthropods,SPECIAL CONCERN,20,AB
2015,Birds,ENDANGERED,41,AB
2012,Arthropods,EXTINCT,32,NS
2012,Arthropods,EXTINCT,1,BC
2016,Lichens,THREATENED,14,MB
2010,Amphibians,ENDANGERED,18,NU
2013,Mosses,THREATENED,41,BC
2015,Mammals,ENDANGERED,33,ON
NOTE
You are not permitted to modify the data file in any way
You will need to ignore the first line of the data file as it contains data header information
main.c
// IPC144 2022 Summer Final Assessment Coding Project
// --------------------------------------------------
// Project idea is based on COSEWIC reports for SAR
//
// COSEWIC: Committee on the Status of Endangered Wildlife in Canada
// SAR: Species At Risk
//
// Source: https://bit.ly/3AEgab9
//
// Note: The data used for this assignment has been fictionalized with invalid counts
#define _CRT_SECURE_NO_WARNINGS
#include
#include "cosewic.h"
#define DATA_FILE "data.txt"
#define MAX_RECORDS 6500
int main(void)
{
int records;
struct FileData data[MAX_RECORDS] = { {0} };
printf("Loading data from file: %sn", DATA_FILE);
records = loadData(DATA_FILE, data, MAX_RECORDS);
printf("%d data records read from file...nn", records);
if (records > 0)
{
// Entry point to application logic
mainLogic(data, records);
}
else
{
printf("Ooooops there seems to have been an error loading data!n");
}
return 0;
}
/* Sample Inputs:
-1
5
1
2
3
4
-1
14
9
-1
11
4
4
7
8
*/
Output
Loading data from file: data.csv
6500 data records read from file...
=======================================================
Canada Species at Risk Analysis
(Data Years: 2010 - 2019)
=======================================================
1. View by year (sorted ASCENDING by year)
2. View by province (sorted DESCENDING by totals)
3. View by taxon (sorted ASCENDING by totals)
4. View by province and taxon
-------------------------------------------------------
0. Exit
-------------------------------------------------------
Selection: -1
Invalid menu selection!
=======================================================
Canada Species at Risk Analysis
(Data Years: 2010 - 2019)
=======================================================
1. View by year (sorted ASCENDING by year)
2. View by province (sorted DESCENDING by totals)
3. View by taxon (sorted ASCENDING by totals)
4. View by province and taxon
-------------------------------------------------------
0. Exit
-------------------------------------------------------
Selection: 5
Invalid menu selection!
=======================================================
Canada Species at Risk Analysis
(Data Years: 2010 - 2019)
=======================================================
1. View by year (sorted ASCENDING by year)
2. View by province (sorted DESCENDING by totals)
3. View by taxon (sorted ASCENDING by totals)
4. View by province and taxon
-------------------------------------------------------
0. Exit
-------------------------------------------------------
Selection: 1
YEAR EXTINCT EXTIRPATED ENDANGERED THREATENED CONCERN TOTAL
---- ------- ---------- ---------- ---------- ------- ---------
2010 3291 3304 3101 3090 3194 15980
2011 3151 3083 3238 3248 3066 15786
2012 3298 3385 3339 3385 3395 16802
2013 3273 3200 3337 3291 3318 16419
2014 3420 3490 3494 3492 3323 17219
2015 3433 3378 3179 3198 3289 16477
2016 3293 3269 3445 3447 3177 16631
2017 3314 3365 3331 3289 3314 16613
2018 3276 3282 3274 3287 3296 16415
2019 3380 3375 3402 3395 3331 16883
------- ---------- ---------- ---------- ------- ---------
33129 33131 33140 33122 32703 165225
=======================================================
Canada Species at Risk Analysis
(Data Years: 2010 - 2019)
=======================================================
1. View by year (sorted ASCENDING by year)
2. View by province (sorted DESCENDING by totals)
3. View by taxon (sorted ASCENDING by totals)
4. View by province and taxon
-------------------------------------------------------
0. Exit
-------------------------------------------------------
Selection: 2
PROVINCE EXTINCT EXTIRPATED ENDANGERED THREATENED CONCERN TOTAL
-------------------- ------- ---------- ---------- ---------- ------- ---------
Ontario 2629 2631 2614 2690 2756 13320
Nunavut 2633 2717 2684 2555 2591 13180
Manitoba 2701 2666 2684 2548 2563 13162
Yukon Territory 2619 2648 2675 2608 2490 13040
New Brunswick 2636 2562 2608 2671 2418 12895
Quebec 2666 2340 2668 2361 2784 12819
Saskatchewan 2562 2571 2550 2671 2340 12694
Nova Scotia 2563 2278 2541 2634 2602 12618
Newfoundland 2383 2619 2395 2695 2501 12593
Alberta 2520 2629 2614 2320 2442 12525
Prince Edward Island 2559 2384 2557 2520 2384 12404
British Columbia 2323 2559 2263 2317 2585 12047
Northwest Territory 2335 2527 2287 2532 2247 11928
-------------------- ------- ---------- ---------- ---------- ------- ---------
33129 33131 33140 33122 32703 165225
=======================================================
Canada Species at Risk Analysis
(Data Years: 2010 - 2019)
=======================================================
1. View by year (sorted ASCENDING by year)
2. View by province (sorted DESCENDING by totals)
3. View by taxon (sorted ASCENDING by totals)
4. View by province and taxon
-------------------------------------------------------
0. Exit
-------------------------------------------------------
Selection: 3
TAXON EXTINCT EXTIRPATED ENDANGERED THREATENED CONCERN TOTAL
--------------- ------- ---------- ---------- ---------- ------- ---------
Molluscs 3096 3329 3194 3151 3061 15831
Lichens 3194 3267 3128 3007 3320 15916
Amphibians 3186 3446 3096 3239 3305 16272
Vascular Plants 3435 3203 3344 3238 3211 16431
Reptiles 3142 2989 3626 3547 3146 16450
Mammals 3333 3351 3186 3421 3203 16494
Arthropods 3626 3407 3256 3310 3176 16775
Mosses 3256 3313 3448 3547 3354 16918
Birds 3434 3268 3427 3317 3478 16924
Fishes 3427 3558 3435 3345 3449 17214
------- ---------- ---------- ---------- ------- ---------
33129 33131 33140 33122 32703 165225
=======================================================
Canada Species at Risk Analysis
(Data Years: 2010 - 2019)
=======================================================
1. View by year (sorted ASCENDING by year)
2. View by province (sorted DESCENDING by totals)
3. View by taxon (sorted ASCENDING by totals)
4. View by province and taxon
-------------------------------------------------------
0. Exit
-------------------------------------------------------
Selection: 4
Choose a Province
----------------------------------
1) AB (Alberta)
2) BC (British Columbia)
3) MB (Manitoba)
4) NB (New Brunswick)
5) NL (Newfoundland)
6) NS (Nova Scotia)
7) NT (Northwest Territories)
8) NU (Nunavut)
9) ON (Ontario)
10) PE (Prince Edward Island)
11) QC (Quebec)
12) SK (Saskatchewan)
13) YT (Yukon Territory)
Selection: -1
Invalid menu selection!
Choose a Province
----------------------------------
1) AB (Alberta)
2) BC (British Columbia)
3) MB (Manitoba)
4) NB (New Brunswick)
5) NL (Newfoundland)
6) NS (Nova Scotia)
7) NT (Northwest Territories)
8) NU (Nunavut)
9) ON (Ontario)
10) PE (Prince Edward Island)
11) QC (Quebec)
12) SK (Saskatchewan)
13) YT (Yukon Territory)
Selection: 14
Invalid menu selection!
Choose a Province
----------------------------------
1) AB (Alberta)
2) BC (British Columbia)
3) MB (Manitoba)
4) NB (New Brunswick)
5) NL (Newfoundland)
6) NS (Nova Scotia)
7) NT (Northwest Territories)
8) NU (Nunavut)
9) ON (Ontario)
10) PE (Prince Edward Island)
11) QC (Quebec)
12) SK (Saskatchewan)
13) YT (Yukon Territory)
Selection: 9
Choose a Taxon
---------------
1) Mammals
2) Birds
3) Reptiles
4) Amphibians
5) Fishes
6) Arthropods
7) Molluscs
8) Vascular Plants
9) Mosses
10) Lichens
Selection: -1
Invalid menu selection!
Choose a Taxon
---------------
1) Mammals
2) Birds
3) Reptiles
4) Amphibians
5) Fishes
6) Arthropods
7) Molluscs
8) Vascular Plants
9) Mosses
10) Lichens
Selection: 11
Invalid menu selection!
Choose a Taxon
---------------
1) Mammals
2) Birds
3) Reptiles
4) Amphibians
5) Fishes
6) Arthropods
7) Molluscs
8) Vascular Plants
9) Mosses
10) Lichens
Selection: 4
*** Data filtered by PROVINCE and TAXON ***
Province: Ontario
Taxon : Amphibians
EXTINCT EXTIRPATED ENDANGERED THREATENED CONCERN TOTAL
------- ---------- ---------- ---------- ------- ---------
280 289 244 288 299 1400
=======================================================
Canada Species at Risk Analysis
(Data Years: 2010 - 2019)
=======================================================
1. View by year (sorted ASCENDING by year)
2. View by province (sorted DESCENDING by totals)
3. View by taxon (sorted ASCENDING by totals)
4. View by province and taxon
-------------------------------------------------------
0. Exit
-------------------------------------------------------
Selection: 4
Choose a Province
----------------------------------
1) AB (Alberta)
2) BC (British Columbia)
3) MB (Manitoba)
4) NB (New Brunswick)
5) NL (Newfoundland)
6) NS (Nova Scotia)
7) NT (Northwest Territories)
8) NU (Nunavut)
9) ON (Ontario)
10) PE (Prince Edward Island)
11) QC (Quebec)
12) SK (Saskatchewan)
13) YT (Yukon Territory)
Selection: 7
Choose a Taxon
---------------
1) Mammals
2) Birds
3) Reptiles
4) Amphibians
5) Fishes
6) Arthropods
7) Molluscs
8) Vascular Plants
9) Mosses
10) Lichens
Selection: 8
*** Data filtered by PROVINCE and TAXON ***
Province: Northwest Territory
Taxon : Vascular Plants
EXTINCT EXTIRPATED ENDANGERED THREATENED CONCERN TOTAL
------- ---------- ---------- ---------- ------- ---------
299 278 196 242 244 1259
=======================================================
Canada Species at Risk Analysis
(Data Years: 2010 - 2019)
=======================================================
1. View by year (sorted ASCENDING by year)
2. View by province (sorted DESCENDING by totals)
3. View by taxon (sorted ASCENDING by totals)
4. View by province and taxon
-------------------------------------------------------
0. Exit
-------------------------------------------------------
Selection: 0
Application Terminated!
data.txt
The file is provided below
https://mega.nz/file/sxBWXAoQ#-WzwUQhVXrcgr4Yq9lG3sym1t2vHZS7sB7YtzjdR1zU
[Show More]