Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c# Tim recently bought a fitbit pedometer that keeps track of how much exercise he does. It outputs the data to a CSV file in
c# 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, fitbitexport.csv which contain valid data, and badfitbit.csv which is used to test task
Here are the first few lines of the file fitbitexport.csv:
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
Introduction to Programming Practicals
You must create a File menu with the following items see the recording in the Week 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 s 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 pseudocode 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
COMPX
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, ie number of steps distance
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 stepsm value to 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 BARWIDTH after each bar is drawn, ie X BARWIDTH, and the height of the bar is the distance walked SCALEFACTOR.
Start off with the Y position 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started