BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C++代写 | COMP2011 Assignment 4: COVID-19 Outbreak Data Analysis

C++代写 | COMP2011 Assignment 4: COVID-19 Outbreak Data Analysis

这个作业是用C++根据COVID-19大流行的数据,计算发病率和死亡率
COMP2011 Assignment 4: COVID-19 Outbreak Data Analysis 2.0
Introduction
This programming assignment is an extension of the COVID topic from PA3. It aims at practicing the usage of class and data I/O operations. Your tasks involve implementing two classes
and their member functions, reading data from CSV files with dynamic allocation, doing a bit of processing on the data using class member functions, and writing the output to CSV files.
Background and data
The background and motivation of this task are the same as that of PA3. You have collected some raw data, including numbers of confirmed cases and deaths. To help analyze the
COVID-19 pandemic, you want to know more information, like morbidity and mortality rate (deaths / total cases).
The data is created and maintained by Johns Hopkins University Center for Systems Science and Engineering. We are only using it for educational purposes. You may find the original
data in the online source of the data on Github. In the assignment, we prepare one CSV file for you. This file is generated by merging two raw files,
time_series_covid19_confirmed_global.csv and time_series_covid19_deaths_global.csv. It records the time series data of confirmed cases and deaths from 22, Jan 2020 to 5, May 2020.
Furthermore, we add area and population information for each country (or region). We disclaim all representations and warranties with respect to the data, including accuracy, fitness for
use, and merchantability.
Overview
Workflow
The procedure is as follows. First, read data from a CSV file (we provide two different source files for you to experiment with. pa4_data.csv is for final submission, pa4_data_short.csv is
only for testing). Second, do processing on the time series data. The processing includes computing rates of confirmed cases and deaths normalized by area (per 1,000km^2), rates of
confirmed cases and deaths normalized by population (per 1,000,000 people), and mortality rate for each country (or region). To normalize, you simply divide by the provided population
or area, respectively. Third, store the results of each computed statistic into different CSV files.
Please see the main.cpp and the sample output for specific details.
Task 1: Read csv
You are given a csv file which is the format of
name,population,area,cases1,deaths1,cases2,deaths2,cases3,deaths3,…
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Each line records information of one country (or region). It includes the population (people), the area (km^2), the numbers of cases, and the numbers of deaths per day starting from
January 22, 2020. You need to implement the function to read this csv file.
int readcsv(Region*& region, const char* csvFileName);
In this function, an array of Region will be constructed to store all of the information read from the CSV file. The first parameter region denotes this array, passed by reference.
csvFileName is the path to this file. The return value is the length of this array, i.e. the number of recorded countries (or regions), which will be used in task 3 later.
In order to complete this task, you simply have to read in each line and then call and implement the readline() function in the Region class discussed in more detail in Task 2 below.
That function will take a line that you read from the CSV and populate the data members of that instance of the class with the information from the file. So, please read Task 2 before
starting to understand how that function is called. For better understanding, we provide the pseudocode:
readcsvs{
load the CSV file;
allocate for an array of Region;
for each line in the CSV file:
readline();
}
You should keep all data read from the file, i.e., you do not need to remove any days that have zero cases like PA3.
You may assume the maximum length of one line is 2048.
Task 2: Implement the Class functions
You need to implement the functions of two classes, DayStat and Region.
DayStat keeps a pair of cases and deaths statistics for a given day. Its definition is shown below:
class DayStat
{
private:
double cases, deaths;
public:
DayStat();
DayStat(int _cases, int _deaths);
DayStat(const DayStat &d, int denominator);
double mortalityRate() const;
double getcases() const;
double getdeaths() const;
};
DayStat stores numbers (or rates) of confirmed cases and deaths of one certain day as its private member variables cases and deaths. It has three types of constructor functions. The first
one is the default constructor and initializes two member variables to 0. The second one sets the member variables based on the passed parameters. The third one takes another DayStat
and a denominator as input, computing rates normalized by the given denominator, and storing them as its member variables. Hints: The second constructor function is used when reading
raw data. The third constructor function is used for computing rates given raw data and one denominator.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
mortalityRate computes mortality rate (percentage of cases that resulted in death) based on its two member variables. If there are no cases, you should set it directly to zero to avoid a
division by zero error. Its minimum value should be zero, and the maximum should be 100. Finally, getcases() and getdeaths() are used to access the values of cases and deaths,
respectively. (Because they are private members and we cannot access them outside the class.)
The definition of Region is shown below. It stores the time series data of one country (or region).
class Region
{
private:
DayStat *raw;
char *name;
int population;
int area;
int nday;
DayStat *normPop;
DayStat *normArea;
double *mortality;
public:
Region();
~Region();
void readline(char *line);
void normalizeByPopulation();
void normalizeByArea();
void computeMortalityRate();
void write(Stat stat) const;
};
We use DayStat arrays to store time series data. The input “raw” data is stored in the raw dynamic array which you should create when reading from file. name, population, and area
represent the name, the population, and the area of this country (or region). nday is the number of recorded days, i.e. the length of DayStat arrays. The rates normalized by population and
area are stored as normPop and normArea, respectively. The array mortality stores the time series data of mortality.
Region is the default constructor function which initializes members to 0 or nullptr where appropriate. The destructor function should release the memory. The function readline() takes
one char array as input and fills in the information in the first five member variables. Note that you must dynamically allocate the raw array at this point. normalizeByPopulation()
computes rates normalized by population (per 1,000,000 people) and stores them in normPop. normalizeByArea() computes rates normalized by area (per 1,000km) and stores them in
normArea. computeMortalityRate() computes mortality rates and stores them in mortality. Finally, the last member function write() save time series data into CSV files (please see
Task 3 before implementing it so that you have an idea of how it will be used).
Please see todo.h and sample output for examples to check your understanding.
Task 3: Write CSV
Finally, you need to implement this function shown below.
void writecsvs(const Region* region, int nRegions);
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
The parameter region refers to the array of Region , each element of which contains the information of one country (or region). The parameter nRegions is the length of this array, i.e.
the number of recorded countries (or regions). The value of nRegions comes from task 1.
Please note that just like readcsv(), writecsvs() mainly implements the workflow that processes each element in the array region. As the variables of region are private, we can only
modify them in the member functions of region. Therefore, the I/O operation is actually performed in write.
For better understanding, we provide the pesudocode:
writecsvs{
for each Region in the array:
write();
}
You need to generate 7 CSV files in total, which contain numbers of confirmed cases (raw data), numbers of deaths (raw data), rates of confirmed cases (normalized by population), rates
of deaths (normalized by population), rates of confirmed cases (normalized by area), rates of deaths (normalized by area), and mortality rate, respectively. We list the name of these 7
CSV files as an enum.
enum Stat {CASESRAW, DEATHSRAW, CASESPOP, DEATHSPOP, CASESAREA, DEATHSAREA, MORTALITY};
Note: Please pay attention to the format of the numbers in your output. You should make sure that the numbers have 6 significant figures. (e.g. 0 and 123456e-6 are not the right format.
They should be 0.000000 and 0.123456.) Please check if there are inf or nan in your outputs before you submit them.
You may call fstream::precision() to set the precision in csv files. Please make sure the precision in your outputs is 6 (default value).
You may call fstream::setf(ios::fixed) to control the format of output numbers. Please avoid scientific notations () in your outputs.
Skeleton
Note: There is a typo in the former version. In the todo.cpp, line 16, the type of the second parameter should be changed from int into double. We have updated the link below.
The skeleton code can be downloaded here. Unzip it, and add all of them to your Eclipse project. The CSV file should be placed under the same folder as the source files.
To reduce your workload, we have finished and provided main.cpp and todo.h. main.cpp contains the main procedure of the program while todo.h contains the definitions of the two
classes and two functions. Please do not modify these two files. You only need to finish the implementation of these two classes as well as some helper functions in todo.cpp.
Notes
You are NOT allowed to include any additional library.
You are NOT allowed to use any global variable nor static variable like “static int x”.
You may use any library function that can be used without including additional libraries. (note: please make sure it is the case in our Windows Eclipse).
You may create and use your own helper functions defined in todo.cpp itself.
You can assume all input is valid and formatted exactly as described
No checking nor validation of parameters is needed in general, unless specifically required in the description
For any dynamic char array, you should make it just big enough to contain all the character content as well as the terminating null character \0 at the end. For example, to store
“Hong Kong”, you should allocate a char array of size 10.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
You should NOT assume the maximum number of characters of any field in the CSV file in your implementations, as we want to test your ability to adapt to using variable-sized
dynamic arrays, although for file I/O simplicity we did assume the maximum line length is 2048 in the given readCSV function.
Sample output
You may download/read the generated console output and csv files. The zipped file contains 7 CSV files. You may want to use some difference checker such as this to compare your
output with the sample output since the sample output is pretty long.
We have also prepared a simpler test case for you to check your program. You may download the input CSV file pa4_data_short.csv, put that in your project folder, and uncomment a line
in main.cpp to test using it. It should produce this sample console output and this output.zip.
Please note that sample output, naturally, does not show all possible cases. It is part of the assessment for you to design your own test cases to test your program. Be reminded to remove
any debugging message that you might have added before submitting your code.
Please note that there is a blank line at the end of each CSV file.
Data Visualization
This part is just for fun. 🙂
Now that you have the processed data in your output csv files, you may copy its content (you may read the content in the csv file in Eclipse or a notepad software), and paste it below to
visualize the data after all the hard work. Have fun!
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Submission
Deadline
23:59:00, May 24 (Sun), 2020
Canvas Submission
1. Submit only the file “todo.cpp” through CANVAS to “Assignment 4”. The filename has to be exactly the same and you should NOT zip/compress the file. Canvas may
append a number to the filename of the file you submit. E.g., todo-1.cpp. It is OK as long as you have named your file as todo.cpp when you submit it.
2. Make sure your source file can be successfully compiled. If we cannot even compile your source file, your work will not be graded. Therefore, you should at least put in dummy
implementations to the parts that you cannot finish so that there will be no compilation error.
3. Make sure you actually upload the correct version of your source files – we only grade what you upload. Some students in the past submitted an empty file or a wrong file or
an exe file which is worth zero mark. So you should download and double-check the file you submit.
4. You may submit your file multiple times, but only the latest version will be graded.
5. Submit early to avoid any last-minute problem. Only canvas submissions will be accepted.
Compilation Requirement
It is required that your submissions can be compiled and run successfully in our official Windows Eclipse which can be downloaded from the “Using Eclipse at home (Windows)”
section here. You need to unzip the zip file first, and then run the Eclipse program extracted from it. Do not just double-click the zip file. If you have used other IDE/compiler/OS
(including macOS Eclipse) to work out your solution, you should test your program in the aforementioned official environment before submission. This version of Eclipse is also installed
on our lab machines.
If you have no access to a standard Windows machine, you may remote control a Windows machine in HKUST virtual barn. Choose the “Programming Software” server, and you will
find Eclipse shortcut on the desktop. This is a newer version of Eclipse with a slightly different interface. However, its compiler has the same version as ours and can be used to verify if
your program can be compiled by us for grading. In particular, to create a new C++ project, you can do so from “File” menu -> “New” -> “Project…” -> “C++ project” -> Type a project
name -> Choose MinGW compiler -> “Finish”. Also, to build the project, save your files, then use the Hammer and Run buttons, circled in the following screenshot (NOT the ones on the
left):
Late Submission Policy
There will be a penalty of -1 point (out of a maximum 100 points) for every minute you are late. For instance, since the deadline of assignment 3 is 23:59:00 on May 12, if you submit
your solution at 1:00:00 on May 13, there will be a penalty of -61 points for your assignment. However, the lowest grade you may get from an assignment is zero: any negative score after
the deduction due to late penalty will be reset to zero. However, all submissions will be subject to our plagiarism detection software, and you will get the cheating penalty as described in
Honor Code if you cheat and get caught.
Checking for memory leak
When we grade your work, we will use valgrind to check for memory leak in your program. Some marks will be deducted if memory leak is detected.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Checking for memory leak is optional for you. Please refer to the same section on PA3 webpage.
FAQ
Q: My code doesn’t work / there is an error, here is the code, can you help me to fix it?
A: As the assignment is a major course assessment, to be fair, you are supposed to work on it on your own and we should not finish the tasks for you. We might provide some very
general hints to you, but we shall not fix the problem or debug for you.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD

bestdaixie