C++ homework project | Computer Science homework help

(1) Learn to create class structure in C++(2) Create an array of objects in C++(3) Search and perform operations on the array of objectsProject Description:The input csv file for this project consists of rows of data that deals with COVID-19 cases and deaths per day for each county in every state in the United States. Here is an example,date,county,state,fips,cases,deaths2020-01-21,Snohomish,Washington,53061,1,02020-01-22,Snohomish,Washington,53061,1,02020-01-23,Snohomish,Washington,53061,1,0For the purposes of this project, we will assume that the following are char* data types: date, county, and state. FIPS (unique identifier for each county) along with cases and deaths are int data types. Please note the comma delimiter in each row. You need ­­­to carefully read each field knowing that you will have a comma.You will use redirected input (more later) to read an input txt file that contains the following:counts  //number of data entries in the csv fileFilename.csv  //this is the file that contains the covid-19 dataCommand  //details of what constitutes a command is given belowCommandCommand….Your C++ program will read the counts value on the first line of the txt file, which represents the number of data entries in the csv file. (Note – the first line of the csv file contains descriptive variable fields, so there will be a total of [number of data entries + 1] lines in the csv file). Then, on the second line, it will read the Filename.csv and open the file for reading (more on how to do this in C++). After you open the file, you will read the data from each row of the csv file and create a COVID19 object. The COVID19 class is given below. You need to implement all of the necessary methods.class COVID19 {protected:char* date;char* county;char* state;int fips;int cases;int deaths;public:COVID19 (); //default constructorCOVID19 (char* da, char* co, char* s, int f,  int ca, int de); //initializerdisplay ();//write all accessors and other methods as necessary};After your write the above class you will write the following class:class COVID19DataSet {protected:COVID19* allData;int count; //number of COVID19 objects in allDataint size; //maximum size of arraypublic:COVID19DataSet (); //default constructorCOVID19DataSet (int initSize);void display ();void addRow (COVID19& oneData);int findTotalCasesByCounty (char* county, char* state); int findTotalDeathsByCounty (char* county, char* state);int findTotalCasesByState (char* state);int findTotalDeathsByState (char* state); int findTotalCasesBySateWithDateRange (char* state,char* startDate, char* endDate);int findTotalDeathsBySateWithDateRange (char* state,char* startDate, char* endDate);~COVID19(); //destructor//other methods as deem important};The structure of the main program will be something like this:#include using namespace std;// Write all the classes hereint main () {int counts; // number of records in Filename.CSVint command;COVID19 oneRow;//read the filename, for example, Filename.csv//open the Filename.csv using fopen (google it for C++ to find out)//assume that you named this file as myFile//read the first integer in the file that contains the number of rows//call this number countsCOVID19DataSet* myData = new COVID19DataSet (counts);for (int i=0; i < counts; i++) {//read the values in each row//use setters to set the fields in oneRow(*myData).addRow (oneRow);} //end for loopwhile (!cin.eof()) {cin >> command;switch (command) {case 1: {//read the rest of the row(*myData).findTotalCasesByCounty (county, state);break; }case 2: { //do what is needed for command 2 break; }case 3: { //do what is needed for command 3 break; }case 4: { //do what is needed for command 4 break; }case 5: { //do what is needed for command 5 break; }case 6: { //do what is needed for command 6 break; }default: cout << “Wrong commandn”;} //end switch} //end whiledelete myData;return 0;}Input Structure:The input txt file will have the following structure – I have annotated here for understanding and these annotations will not be in the actual input file. After the first two lines, the remaining lines in the input txt file contains commands (one command per line), where there can be up to 6 different commands in any order with any number of entries. The command is indicated by an integer [1 to 6] and can be found at the beginning of each line.counts // Number of data entries in the csv file Covid-19-Data-csv  // Name of the input file that contains the actual Covid-19 data by county and state1 Cleveland, Oklahoma //command 1 here is for findTotalCasesByCounty1 Walla Walla, Washington 1 San Francisco, California1 Tulsa, Oklahoma2 Oklahoma, Oklahoma //command 2 here is for findTotalDeathsByCounty2 Miami, Ohio2 Miami, Oklahoma3 Oklahoma //command 3 here is for findTotalCasesByState3 North Carolina4 New York //command 4 here is for findTotalDeathsByState4 Arkansas5 Oklahoma 2020-03-19 2020-06-06 //5 here is for findTotalCasesBySateWithDateRange6 New York 2020-04-01 2020-06-06 //6 here is for findTotalDeathsBySateWithDateRangeRedirected InputRedirected input provides you a way to send a file to the standard input of a program without typing it using the keyboard. To use redirected input in Visual Studio environment, follow these steps: After you have opened or created a new project, on the menu go to project, project properties, expand configuration properties until you see Debugging, on the right you will see a set of options, and in the command arguments type “< input filename”. The < sign is for redirected input and the input filename is the name of the input file (including the path if not in the working directory). A simple program that reads character by character until it reaches end-of-file can be found below.#include using namespace std;//The character for end-of-line is ‘n’ and you can compare c below with this //character to check if end-of-line is reached.int main () {char c;cin.get(c);while (!cin.eof()) {cout << c;cin.get(c);}return 0;}C StringA string in the C Programming Language is an array of characters ends with ‘’ (NULL) character. The NULL character denotes the end of the C string. For example, you can declare a C string like this:char aCString[9];Then you will be able to store up to 8 characters in this string. You can use cout to print out the string and the characters stored in a C string will be displayed one by one until ‘’ is reached. Here are some examples:012345678cout resultLengthusernameusername8namename4name1234name4(nothing)0Similarly, you can use a for loop to determine the length of a string (NULL is NOT included). We show this in the following and also show how you can dynamically create a string using a pointerchar aCString[] = “This is a C String.”; // you don’t need to provide// the size of the array// if the content is providedchar* anotherCString; // a pointer to an array of// charactersunsigned int length = 0;while( aCString[length] != ‘’){length++;}// the length of the string is now knownanotherCString = new char[length+1]; // need space for NULL character// copy the stringfor( int i=0; i< length+1; i++) anotherCString[i] = aCString[i]; cout << aCString << endl; // print out the two stringscout << anotherCSring << endl;delete [] anotherCString; // release the memory after useYou can check http://www.cs.bu.edu/teaching/cpp/string/array-vs-ptr/, other online sources or textbooks to learn more about this.Output StructureStay tuned for the exact format in which the output of your program should be formatted. For now, it is recommended to start working on reading in the input files, storing the data, and accessing the data based on the given commands.Constraints1. In this project, the only header you will use is #include and using namespace std.2. None of the projects is a group project. Consulting with other members of this class our seeking coding solutions from other sources including the web on programming projects is strictly not allowed and plagiarism charges will be imposed on students who do not follow this.Rules for Gradescope (Project 1):1. Students have to access GradeScope through Canvas using the GradeScope tab on the left, or by clicking on the Project 1 assignment submission button.2. Students should upload their program as a single cpp file and cannot have any header files. If, there are header files (for classes) you need to combine them to a single cpp file and upload to GradeScope.3. Students have to name their single cpp file as ‘project1.cpp’. All lower case. The autograder will grade this only if your program is saved as this name.4. Sample input files and output files are given. Your output should EXACTLY match the sample output file given. Please check the spaces and new lines before your email us telling that the ‘output exactly matches but not passing the test cases’. Suggest using some type of text comparison to check your output with the expected.5. Students need to have only one header file(iostream) while uploading to GradeScope. You cannot have ‘pch.h’ or ’stdafx.h’.6. Students cannot have ‘system pause’ at the very end of the cpp file.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *