Prog 4: Divvy Data

Create a C++ program that will quantify and summarize Divvy Bike trip data, using Zybooks section 8.2. Your program will have options to analyze the dataset as a whole, and to analyze patterns and similarities between a weekday (September 1st) and a weekend (September 4th). Running your program will look like what is shown below, also available as a google doc:

Changes made Thursday 10/21:

  1. New datafile uploaded to Zybooks, small enough to be usable in that environment. Sample output recreated to reflect results when using that new smaller dataset.

  2. Datafile selection sub-menu: Option 2 no longer refers to the second datafile as having "50,000+" rides. A new menu option 3 is given to refer to the full dataset, which you may want to use for your own exploration, even though it will not be tested in Zybooks.

  3. Notes include hints on how to convert a string to an integer or double

  4. Menu option 4 (week day vs. weekend) submenu option 2 now is: 2. Proportional 50 column graph with @ for weekday and + for weekend

Divvy Data Sample Output

Notes


You will need to convert strings to numerical values for some parts of your program. Here is an example of how to do this, assuming it runs in a C++ program that has #include <string> at the top:

string s1 = "32767";

string s2 = "3.14159";

int integerValue = stoi( s1); // Convert string s1 to integer, giving 23767

double doubleValue = stod( s2); // Convert string s2 to double, giving 3.14159


Your program must present the following six menu options:

Select a menu option:

1. Select datafile, display rides totals and clean data

2. Display overall trip information.

3. Display percentage of members vs. casual riders

4. Display weekday vs weekend usage

5. Extra Credit: find closest station

6. Exit

Your choice -->


The user must select menu option 1 (select data file...) prior to selecting any other menu options. Failing to do so results in an error message prompting the user to first choose menu option 1.


Menu Option 1

Select the file you would like to read data from. When menu option 1 is selected, your program will then prompt for a sub-menu option asking for which data file to be used, as follows:

Select datafile:

1. Small subset of data with 14 rides to help create your program

2. Week day vs weekend rides

3. All September 2021 data (not tested in Zybooks)

Your selection--> 1

Total # of trips found in datafile: 13

Total # of trips in clean data: 10

The sample above shows how after the datafile is read, your program then displays the total number of trips in the datafile, along with the number of trips considered "clean" data, where all fields for that trip have values in them. Subsequent steps all use the clean data.


Menu Option 2

Provides the following general information on the cleaned data

  • Total # of miles traveled

  • Average length of trips in miles

  • Longest trip ID, start and end locations and distance in miles

This looks like the following:

Total # of miles traveled: 12

Average length of trips in miles: 1.2

Longest trip information below:

-------------------------------

Trip ID: B465E78B601DB5A8

Trip start location: Broadway & Belmont Ave

Trip end location: Broadway & Thorndale Ave

Trip distance in miles: 3.5


Menu Option 3

Display the percentage of casual vs member riders. This looks like the following:

Casual Rider Percentage: 40.0%

Member Rider Percentage: 60.0%

Menu Option 4

Compute and display the number of trips by hour, comparing Divvy bike data for September 1st and 4th. This has a sub-menu as follows:

Select type of display:

1. Counts of rides per hour in the day

2. Proportional 50 column graph with @ for weekday and + for weekend

Your selection--> 1

LargestNumberOfRides is: 1317

Rides per hour for weekday and weekend:

0: 66 324

1: 26 245

2: 18 122

3: 7 55

4: 16 36

5: 86 42

6: 301 70

7: 565 144

8: 556 275

9: 382 437

10: 311 671

11: 402 770

12: 495 915

13: 428 852

14: 436 819

15: 602 881

16: 845 876

17: 1317 822

18: 1093 751

19: 821 611

20: 533 461

21: 442 376

22: 305 477

23: 174 375


Selecting the sub-menu option 2 gives an ASCII graphics scaled graph. To create this graph first find the largest number of rides for any hour of either the weekday or weekend. For each displayed value figure out what it is as a fraction of this largest value. Multiply that by 50 to give the number of characters to be displayed. See the google doc sample output near the top of this page for sample output after choosing this menu option.

Menu Option 5 (Extra Credit)

Search Google to find a really nice home in Chicago you would like to live in. In Google maps and click on that home to create a "pin" at that spot. Then right click on the pin to display location information. Click on the latitude,longitude information shown to copy those numbers. Use those numbers as input to your program, which then should figure out and display the Divvy station closest to that location. See the google doc sample output near the top of this page for sample output after choosing this menu option.


Menu Option 6

Exit the program.



The various data files are given below:

  1. prog4StyarterCode.cpp 2 KB

  2. divvyridesampledata.csv 2 KB

  3. weekdayweekend.csv 7.6 MB

  4. all_divvy_rides_september.csv 108.9 MB


The starter code includes functions to calculate distance from a pair of latitude,longitude values.

The format of the comma-separated values (csv) data files is the same. Following is the contents of the above-linked divvyridesampledata.csv, followed by the same information displayed when viewed using a spreadsheet application.

ride_id,rideable_type,started_at,ended_at,start_station_name,end_station_name,start_lat,start_lng,end_lat,end_lng,member_casual

E07475A697F1E70B,classic_bike,9/1/21 0:13,9/1/21 0:15,Clark St & Chicago Ave,Clark St & Elm St,41.89675,-87.63089,41.902973,-87.63128,member7
E3274801B3930F3,classic_bike,9/1/21 5:52,9/1/21 6:51,Rush St & Superior St,Michigan Ave & Oak St,41.89576475,-87.62590803,41.90096039,-87.62377664,casual
866C563C76C4BFDF,electric_bike,9/1/21 12:11,9/1/21 13:39,LaSalle St & Illinois St,Sheffield Ave & Willow St,41.89066933,-87.63150067,41.91364,-87.65262567,memberBD6C843E4D352005,docked_bike,9/1/21 10:54,9/1/21 11:16,Museum of Science and Industry,Museum of Science and Industry,41.791728,-87.583945,41.791728,-87.583945,casual99C2180D2DA1318E,electric_bike,9/1/21 14:25,9/1/21 14:36,,Rockwell St & Eastwood Ave,41.93,-87.7,41.9657405,-87.69361183,member5A60EF22D237C789,electric_bike,9/4/21 2:29,9/4/21 2:58,,,41.93,-87.66,41.9,-87.68,casualF0983F87C185DA6A,classic_bike,9/4/21 12:50,9/4/21 12:56,Sheridan Rd & Lawrence Ave,Broadway & Wilson - Truman College Vaccination Site,41.969517,-87.654691,41.965221,-87.658139,casual2D7FD175ADC44F71,classic_bike,9/4/21 12:50,9/4/21 13:24,Lakefront Trail & Bryn Mawr Ave,Seeley Ave & Roscoe St,41.9840367,-87.65231047,41.943403,-87.679618,memberB465E78B601DB5A8,classic_bike,9/4/21 19:17,9/4/21 19:43,Broadway & Belmont Ave,Broadway & Thorndale Ave,41.940106,-87.645451,41.98974251,-87.66014062,member12907BAAAED46484,classic_bike,9/4/21 20:46,9/4/21 21:00,Honore St & Division St,Wells St & Evergreen Ave,41.903119,-87.673935,41.906724,-87.63483,member753CB15A8B3E6A3F,docked_bike,9/4/21 20:46,9/4/21 22:48,Millennium Park,Michigan Ave & Washington St,41.881032,-87.624084,41.883984,-87.624684,casual0CDA1DCA8E980FA8,electric_bike,9/4/21 20:46,9/4/21 20:49,Sheffield Ave & Wrightwood Ave,Greenview Ave & Fullerton Ave,41.92864033,-87.653872,41.92538233,-87.66582083,member3246A2D28095F041,electric_bike,9/4/21 20:46,9/4/21 21:11,,Kedzie Ave & Milwaukee Ave,41.93,-87.65,41.92957283,-87.7078205,casual