” COMP2011程序 写作、Data Analysis程序 辅导COMP2011 Assignment 4: COVID-19 Outbreak Data Analysis 2.0IntroductionThis 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 involveimplementing two classes and their member functions, reading data from CSV files with dynamic allocation, doing a bit of processing on the data using class memberfunctions, and writing the output to CSV files.Background and dataThe 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. Tohelp 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 mayfind 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, Jan2020 to 5, May 2020. Furthermore, we add area and population information for each country (or region). We disclaim all representations and warranties with respectto the data, including accuracy, fitness for use, and merchantability.OverviewWorkflowThe 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 deathsnormalized 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 (orregion). 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 csvYou are given a csv file which is the format ofname,population,area,cases1,deaths1,cases2,deaths2,cases3,deaths3,…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 perday 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, passedby 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 intask 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 moredetail 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 fromthe 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 functionsYou 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 ofconstructor functions. The first one is the default constructor and initializes two member variables to 0. The second one sets the member variables based on thepassed parameters. The third one takes another DayStat and a denominator as input, computing rates normalized by the given denominator, and storing them as itsmember variables. Hints: The second constructor function is used when reading raw data. The third constructor function is used for computing rates given raw dataand one denominator.COMP2011 Assignment 4: COVID-19 Outbreak Data Analysis 2.0Assignment 4IntroductionOverviewNotesSample outputData visualizationSubmissionChecking for memory leakFAQPrepared by: YishuoZHANG2020/5/20 COMP2011 Assignment 4: COVID-19 Outbreak Data Analysis 2.0 httpss://course.cse.ust.hk/comp2011/assignments/assignment4/ 2/4mortalityRate computes mortality rate (percentage of cases that resulted in death) based on its two member variables. If there are no cases, you should set itdirectly 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() areused 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 ofDayStat arrays. The rates normalized by population and area are stored as normPop and normArea, respectively. The array mortality stores the time seriesdata of mortality.Region is the default constructor function which initializes members to 0 or nullptr where appropriate. The destructor function should release the memory. Thefunction 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 rawarray 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 andstores 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 youhave an idea of how it will be used).Please see todo.h and sample output for examples to check your understanding.Task 3: Write CSVFinally, you need to implement this function shown below.void writecsvs(const Region* region, int nRegions);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 thelength 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 regionare 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 (normalizedby 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 arenot 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.SkeletonNote: 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 haveupdated 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 sourcefiles.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 thedefinitions 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 assome helper functions in todo.cpp.NotesYou are NOT allowed to include any additional library.2020/5/20 COMP2011 Assignment 4: COVID-19 Outbreak Data Analysis 2.0 httpss://course.cse.ust.hk/comp2011/assignments/assignment4/ 3/4You 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 describedNo checking nor validation of parameters is needed in general, unless specifically required in the descriptionFor 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.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 tousing 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 outputYou 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 asthis 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 projectfolder, 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 yourprogram. 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 VisualizationThis 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 notepadsoftware), and paste it below to visualize the data after all the hard work. Have fun!SubmissionDeadline235900,May 26 (Tue), 2020 (extended)Canvas Submission.Submit only the file todo.cpp through CANVAS to Assignment 4. The filename has to be exactly the same and you should NOT zip/compressthe 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 asCovid Trend VisualizerPaste any of your seven output CSV files into the text field below and click update to visualize your own results. To avoid displaying a cluttered graph, you may want toonly copy the lines for a few specific regions. As an example, below are lines for Mainland China, Italy, Spain, and United States.Note that this visualizer is just for you to explore your results and it is optional. No robust error checking on the CSV data has been implemented. Make sure the data isin the correct format with one region per line and with no extra lines. In case of a data input error when you click the update button, reload the page before tryingagain.Once the animation is complete, you may move your mouse over the large number label to move back and forth in the timeline.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 atleast put in dummy implementations to the parts that you cannot finish so that there will be no compilation error..Make sure you actually upload the correct version of your source files – we only grade what you upload. Some students in the past submitted anempty 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..You may submit your file multiple times, but only the latest version will be graded..Submit early to avoid any last-Minute problem. Only canvas submissions will be accepted.Compilation RequirementIt is required that your submissions can be compiled and run successfully in our official Windows Eclipse which can be downloaded from the Using Eclipse athome (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 youhave used other IDE/compiler/OS (including macOS Eclipse) to work out your solution, you should test your program in the aforementioned official environmentbefore 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 Softwareserver, 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 sameversion 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 Filemenu – New – Project… – C++ project – Type a project name – Choose MinGW compiler – Finish. Also, to build the project, save your files, then usethe Hammer and Run buttons, circled in the Following screenshot (NOT the ones on the left):Late Submission PolicyThere 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 235900onMay 12, if you submit your solution at 10000on May 13, there will be a penalty of -61 points for your assignment. However, the lowest grade you may get from anassignment 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 plagiarismdetection software, and you will get the cheating penalty as described in Honor Code if you cheat and get caught.Checking for memory leakWhen 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.Checking for memory leak is optional for you. Please refer to the same section on PA3 webpage.FAQQ: My code doesnt 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. Wemight provide some very general hints to you, but we shall not fix the problem or debug for you.如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。