Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

language: c++ CS 1336, Project Assignment 5 Bike Tracking Fitness Write a program that will allow you to track times on an exercise bike for

language: c++

CS 1336, Project Assignment 5 Bike Tracking Fitness

Write a program that will allow you to track times on an exercise bike for several groups, which are stored in a file. Your submission on eLearning should use the following names: cs1336p05yourName.cpp and cs1336p05screenshotYourName.jpg

Description of the problem

The program will read and tabulate a set of data from a file. Each record in the file will be in the following format:

Date in month/day/year format (mm/dd/yyyy). Four-character group code (e.g., CS, ATEC) (max of 4 characters) Twenty-character name of an individual (max of 20 characters) Integer time (1-120)

Month, day, and year should be validated for correctness year should be no earlier than 2015 and no later than 2017. Years can be either four digits (2016) or two (16). No need to validate that a date is not in the future. Verify that date components are separated by slashes and valid values.

White space may be used to separate fields after the date.

Group code is alphanumeric and contiguous (no embedded blanks). Note that an individual should only belong to one group.

Name is alphabetic plus (single quote) and -. Name is contiguous, e.g., JohnDoe. Records may be entered in any order. Any invalid record should be reported and ignored in the tabulations. You may assume that there are no more than 2,000 records, 100 individuals, and 10 groups.

After reading in the data from the input file, tabulate the total times by each group per month for the months reported (no output if no data reported for the month). Tabulate the min, max, and average times per individual across all records.

Test cases: use the data file cs1336p05data.txt to test your program. A printout with the errors circled is also attached for your information in cs1336p05dataErrors.pdf.

Grading Rubric

The program should use functions for reading in the records; validating the date, validating the name of a group, validating the name of an individual, validating bike time; sorting the records; printing the group tabulation; printing the individual tabulation. 70 points.

Symbolic constants are used appropriately; global variables are not used; information hiding (the principle of least privilege) is appropriately applied. 10 points.

The program as a whole is appropriately commented. 10 points. Each function is appropriately commented. 10 points.

data file cs1336p05data.txt:

01/01/2015 CS JohnOne 60 1/2/15 CS JohnOne 80 1/3/2015 CS JohnOne 120 2/29/2016 CS JohnOne 80 2/2/16 CS JohnOne 45 9/31/17 CS JohnOne 30 2/29/2017 CS JohnOne 89 6/15/16 CS JohnOne 82 6/13/16 CS JohnOne 25 2/15/16 CS JohnOne 50 9/1/17 CS JohnOne 45 9/2/17 CS JohnOne 40 9/3/2017 CS JohnOne 38 01/01/2015 ATEC JaneTwo 60 1/2/15 ATEC JaneTwo 80 1/3/2015 ATEC JaneTwo 120 02/28/2016 ATEC JaneTwo 80 2/2/16 ATEC JaneTwo 45 9/30/17 ATEC JaneTwo 30 2/28/2017 ATEC JaneTwo 89 6/15/16 ATEC JaneTwo 82 13/13/16 ATEC JaneTwo 25 3/15/2016 ATECJaneTwo 33 1/15/16 ATEC JaneTwo 50 9/01/17 ATEC JaneTwo 45 9/1/14 ATEC JaneTwo 76 9/5/15 ATECZZZZ JaneTwo 110 9/2/17 ATEC JaneTwo 40 9/3/2017 ATEC JaneTwo 38 01/01/2015 MECH CharlesThree 60 1/2/15 MECH CharlesThree 80 1/3/2015 MECH CharlesThree 120 2/29/2016 MECH CharlesThree 80 2/2/16 MECH CharlesThree 45 9/15/17 MECH CharlesThree 30 9/28/2017 MECH CharlesThree 89 6/15/16 MECH CharlesThree 82 3/13/16 MECH CharlesThree 25 3/15/16 MECH CharlesThree 50 9/1/17 MECH CharlesThree 45 9/2/17 MECH CharlesThree 40 9/3/2017 MECH CharlesThree 38 01/01/2015 ATEC DavidFour 65 1/2/15 ATEC DavidFour 86 1/33/2015 ATEC DavidFour 120 2/28/2016 ATEC DavidFour 82 22/2/16 ATEC DavidFour 2/3/16 ATEC DavidFourTooLongOfANameIsThis 30 9/30/17 ATEC DavidFour 34 2/28/2017 ATEC DavidFour 89 6/15/16 ATEC DavidFour 87 3/13/16 ATEC DavidFour 98 3/15/2016 ATECDavidFour 88 1/15/16 ATEC DavidFour 140 9/1/17 ATEC DavidFour 110 9/1/14 ATEC DavidFour 100 01/01/2015 ATEC EdFive 60 1-15-2016 ATEC EdFive 70 1/2/15 ATEC EdFiveeeeeeeeeeeeeeeeeee 80 1/3/2015 ATEC EdFive 121 2/28/2016 ATEC EdFive 80 2/2/16 ATEC EdFive 45 4//2017 ATEC EdFive 42 4/30/17 ATEC EdFive 30 2/28/2017 ATEC EdFive 89 4//15/16 ATEC EdFive 82 3/13/16 ATEC EdFive 25 3/15/2016 ATECEdFive 33 1/15/16 ATEC EdFive 50 9/1/17 ATEC EdFive 45 9/1/14/ ATEC EdFive 76 2/28/2017 MECH FrankSix 80 6/15/16 MECH FrankSix 90 3/13/16 MECH FrankSix 100 1/15/16 MECH FrankSix 110 9/1/17 MECH FrankSix 120 9/2/17 MECH FrankSix 40 9/1/17 MECH GeorgeD'Ambrose 120 9/2/17 MECH GeorgeD'Ambrose 40 9/1/17 MECH HenrySmyth-Jones 120 9/2/17 MECH HenrySmyth-Jones 40 

Errors shown:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Outline that needs to be followed:

struct Record

{

string date;

string group;

string name;

int time;

bool is_valid()

{

return is_valid_date() && is_valid_group() && is_valid_name() && is_valid_time();

}

bool is_valid_date()

{

// TODO: implement required checks

}

bool is_valid_group()

{

// TODO

}

bool is_valid_name()

{

// TODO

}

bool is_valid_time()

{

// TODO

}

void read(ifstream& ifs) {

ifs >> date >> code >> name >> time;

}

void print(ostream& ofs)

{

// output this as a line (similar to line in error file)

}

}

bool compare_group_date(Record& a, Record& b)

{

// TODO: implement to compare group followed by name

}

bool compare_name(Record& a, Record& b)

{

// TODO: implement to compare name

}

void main()

{

// i am assuming they taught you vector, else you have to do array

vector records;

ifstream ifs;

ofstream out;

ofstream err;

// open these files

while(!ifs.eof()) {

Record rec;

rec.read(ifs);

if(rec.is_valid()) {

records.push_back(rec); // add valid record to vector

} else {

rec.print(err);

}

}

// tabulate total per group per month

sort(records.begin(), records.end(), compare_group_date);

// records are sorted like this

// group1, 01/01/2015

// group1, 02/01/2015

// group3, 01/01/2015

// TODO: write a loop to get total for each group each month

// tabulate min, max, for each person

sort(records.begin(), records.end(), compare_name);

// records are sorted like this

// David, 01/01/2015

// David, 02/01/2015

// John, 03/01/2017

// TODO: write loop to get min max etc for each person

}

also read in day, month, year for each record instead of a single string date field

Three int fields (month, day, year) instead of single date field

01/01/2015 CS JohnOne 60 1/2/15 CS JohnOne 80 1/3/2015 CS JohnOne 120 2/29/2016 CS JohnOne 80 2/2/16 CS JohnOne 45 931/17 CS JohnOne 30 2/29/2017 CS JohnOne 89 6/15/16 CS JohnOne 82 6/13/16 CS JohnOne 25 2/15/16 CS JohnOne 50 9/1/17 CS JohnOne 45 9/2/17 CS JohnOne 40 9/3/2017 CS JohnOne 38 01/01/2015 ATEC JaneTwo 60 1/2/15 ATEC JaneTwo 80 1/3/2015 ATEC JaneTwo 120 02/28/2016 ATEC JaneTwo 80 2/2/16 ATEC JaneTwo 45 9/30/17 ATEC JaneTwo 30 2/28/2017 ATEC JaneTwo 89 6/15/16 ATEC JaneTwo 82

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

Students also viewed these Databases questions