Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Tim recently bought a fitbit pedometer that keeps track of how much exercise he does. It outputs the data to a CSV file in the

Tim recently bought a fitbit pedometer that keeps track of how much exercise he does. It outputs the data to a CSV file in the following format: Date, Calories Burned, Steps, Distance, Minutes Sedentary (Inactive), Minutes Lightly Active, Minutes Fairly Active, Minutes Very Active, Activity Calories.
A data files has been provided, fitbit-export.csv which contain valid data, and bad-fitbit.csv which is used to test task 5.
Here are the first few lines of the file fitbit-export.csv:
01-03-2014,2766,5589,4.24,1165,164,111,0,111002-03-2014,2511,3706,2.81,1275,93,72,0,68303-03-2014,2831,7886,5.99,1228,87,106,19,1060
You are to write a program that will read in a CSV file of fitbit data, process this data and display the data using graphs and a listbox.
Some constants and methods have already been provided for you. Read the comments for the methods to see what they do.
78
Introduction to Programming Practicals
You must create a File menu with the following items (see the recording in the Week 10 section on Moodle on how to create a menu system):
Open File...
Clear
-
Exit
a) The pictureboxes and listbox have been provided for you (the second picturebox will be used in Week 11s practical). Create the File menu as specified above also assigning appropriate shortcut keys.
b) Write the click event method for the Exit menu item which will exit from the application. Write the click event method for the Clear menu item which will clear the listbox and clear the first picturebox.
c) As practice, write the pseudo-code for the Open File... menu item as described in tasks e) to j) below.
d) Create any extra constants that could be used in the application.
e) Create the click event method for the Open File... menu item and then write the C# code as described below:
The Open File menu item will ask for the name of the input file and check that the user clicks on the OK button of the dialog control. It will then open the file and read in the file until the end of file is reached. For each line it reads from the file, the program will split it and then extract the values from the string array into separate variables. It will then display the information in the listbox lined up in columns.
Note: You DO NOT need to store the data into arrays. Just extract the values into separate variables.
Hint: Use the PadRight or PadLeft methods to line up the text.
f) Modify your Open File... menu event method so that it checks for bad data in the file, such as the correct number of elements (commas) on a line, or the numbers parsing correctly. If it doesnt have the correct number of elements, or catches an exception then
79
COMPX101
Introduction to Programming
g) h)
i)
j)
write the raw line to the console window. Test this using the bad- fitbit.csv data file.
Extend your Open File... event so that while reading in the data, it adds up all the steps values, so that at the end of the file it can display the number of steps taken that month in a MessageBox.
Write a method called CalculateStepsPerMetre that accepts an integer, which is the number of steps, and a double, which is the distance walked in kilometres, and returns a double, which is the number of steps Tim walks per metre, i.e. number of steps /(distance *1000).
Extend your Open File... event so that it calls your CalculateStepsPerMetre method after it has successfully converted the data. Alter the display from task e) to also display the steps/m value (to 3 decimal places) as an extra column after the active calories.
Extend your Open File... event so that it displays the distance walked in the top picturebox as a bar graph, by drawing a bar for each day using the DrawBar method provided. The X position of the bar is shifted across by BAR_WIDTH after each bar is drawn, i.e. X += BAR_WIDTH, and the height of the bar is the distance walked * SCALE_FACTOR.
Start off with the Y position =0, so all the bars hang down, then change the Y position so all bars rise from the bottom of the picturebox. See the example screenshot in the template folder.

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions