Question: C++ PROGRAM HELP!!!!! Write a program to analyze death statistics provided by the US government... THIS PROGRAM WILL ACCESS A .CSV FILE FROM THE USER
C++ PROGRAM HELP!!!!!
Write a program to analyze death statistics provided by the US government...
THIS PROGRAM WILL ACCESS A .CSV FILE FROM THE USER AND YOU SHOULD BE ABLE TO DO THE FOLLOWING:
The bolded columns are the cells that you will need to collate for this assignment. From this data, you must allow the user to make several queries:
List total deaths for a given state
List deaths by cause for a given state
List death rates by year for a given state and a given cause
List total death rates by year for a given state
List total deaths for each cause for all states
List total deaths for all causes for all states
List death rates by year for all states and a given cause
List total death rates by year for all states
SHOULD LOOK LIKE THIS:
| ***Death Rate Data Analysis*** Enter State (-1 for all states): California Enter Cause (-1 for all causes): Unintentional Injuries Do you want this data broken down by year (Y/N)?: N Total deaths in California from Unintentional Injuries in the years 1999 to 2015: 180908 Would you like to run another query (Y/N)?: N |
GIVEN STRINGSPLITTER TO HELP PARSE THE FILE....
| #ifndef STRINGSPLITTER_H | |
| #define STRINGSPLITTER_H | |
| #include | |
| #include | |
| using namespace std; | |
| class StringSplitter | |
| { | |
| public: | |
| //Accepts a string and a delimiter. Will use items_found to return the number | |
| //of items found as well as an array of strings where each element is a piece of | |
| //the original string. | |
| static vector | |
| { | |
| //vectors are dynamically expanding arrays | |
| vector | |
| //find the first delimiter | |
| int location = text.find(delimiter); | |
| //we are starting at the beginning of our string | |
| int start = 0; | |
| //go until we have no more delimiters | |
| while(location != string::npos) | |
| { | |
| //add the current piece to our list of pieces | |
| string piece = text.substr(start, location - start); | |
| pieces.push_back(piece); | |
| //update our index markers for the next round | |
| start = location + 1; | |
| location = text.find(delimiter, start); | |
| } | |
| //at the end of our loop, we're going to have one trailing piece to take care of. | |
| //handle that now. | |
| string piece = text.substr(start, location - start); | |
| pieces.push_back(piece); | |
| return pieces; | |
| } | |
| }; | |
| #endif
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
