Question: Write a program that reads a persons physical activity from a file, collects statistics by month, and prints a table showing those statistics. The program

Write a program that reads a persons physical activity from a file, collects statistics by month, and prints a table showing those statistics. The program should prompt the user for the name of the file. This file contains information on the number of steps a person has taken on a given day. Each line of the file is of the form #1/#2 #3 where:

#1 is the one or two-digit month, ranging from 1 to 12

#2 is the one or two-digit day of the month, ranging from 1 to 31

#3 is the number of steps the person walked that day If a line in the file contains something other than data of this format, that line should be ignored and a warning printed to the user about the ignored line.

White space between values are not considered relevant and should not impact the validity of a line. Dont worry about the same day appearing multiple times in the file that is guaranteed not to happen. Lines consisting of only whitespace should be ignored. While reading the file, the program should capture and calculate the minimum number of steps taken in each month and the day those steps were taken, the maximum number of steps taken in each month and the day those steps were taken, the total number of steps taken in each month, and the average number of steps taken each day in a month (only for the days that have steps provided dont include days without steps in the average). After reading all the data in the file, the program should print a nicely formatted table with all the statistics gathered and calculated. Your program should validate the data as much as possible. In addition, the program should recover from unexpected input as much as possible.

Do NOT use arrays in this program.

HINT: Start with input files that contain only well-formed, valid input. Then gradually introduce invalid data into the input file and ensure your program handles it as well as possible.

Here is a sample input file for the program. This sample input file has some issues!

Write a program that reads a persons physical activity from a file,

DO NOT IMPLEMENT A PARSER PLEASE.

Here is the sample output of the professor's solution for this project. Please enter the relative or absolute path of the input file: input1.txt Unable to read month (or reached end-of-file) from line 1 of the input file Did not find expected slash from line 2 of the input file Unable to read activity from line 3 of the input file Invalid step count (or end-of-file) from line 12 of the input file Unexpected characters found on line 13 of the input file Did not find expected slash from line 17 of the input file Unable to read activity from line 18 of the input file Unable to read day (or reached end-of -file) from line 19 of the input file I-Maximum---Minimum--ITotal--IAverage--I -Day-Count--Day--count-1-StepsISteps-- 1 100011 3 3000 21 15412 1 3500 4300 3000 61 2123 1 3500 233031 30001 22035I 35001 9001 JanuaryI 7767.67 30001 7345 1 35001 9001 February March April May 9001 9001 June July August September I OctoberI November I December25 8 3456 8 3456 3456 3456 1 25 1I

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!