Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

General Information This lab emulates part of the code for a fitness tracker app. It determines how many equivalent miles have been walked. Detailed Information

General Information

This lab emulates part of the code for a fitness tracker app. It determines how many equivalent miles have been walked.

Detailed Information

We dont have the input device of a fitness tracker, so well get our input from a file, but the program we will write is similar to the code that would be part of a fitness tacker app. You each need to track your activity for two weeks and enter it in the spreadsheet I emailed to you where youll keep track of activities and minutes spent. Use the codes below to indicate the activity.

Activity

Steps in 1 minute

Code

Basketball game

242

0

Bicycling

242

1

Cooking

61

2

Dance

167

3

Football

242

4

Hiking

182

5

House cleaning

91

6

Miniature golf

91

7

Racquetball

212

8

Rowing

212

9

Running

348

10

Soccer

212

11

Softball

152

12

Stairs

273

13

Swimming laps

212

14

Tennis

212

15

Walking

100

16

Weight lifting

121

17

Yoga

76

18

Heres the beginning of my sample spreadsheet. It lists my name and height in inches (62.5) followed by the number of activities on the next lines, 3, in this case. The following rows list activities. So, 14 is Walking above and I walked for 45 minutes. I ran (code=9) for 15 minutes, and I practiced yoga (code=16) for 45 minutes.

The program starts by asking the user for the name of an input file.

If the file doesnt exist, print the following error message where ________ is the file name and end the program.

File ________ does not exist. Please contact the administrator.

If the file is empty, print the following error message where ________ is the file name and end the program.

File _________ is empty. Please contact the administrator.

If the file exists and is non-empty, it will be in the following format with the data in it from all students in the class. So, it will have the data for more than one person in it. I will create this text file by adding all of your data to one spreadsheet then saving it from MS Excel as a space delimited, formatted text file (*.prn). So, the text file created from the MS Excel spreadsheet with just my data in it would look like:

The program prints a welcome message then reads the file into an array of structures (assuming the file exists and is non-empty; otherwise see above). The program then sorts the array by the number of equivalent miles walked per person in descending order (largest first), calculates total miles walked by everyone, prints a table formatted as shown below and goodbye message, and ends. Names will be no longer than 20 characters. Total miles will be less than 99,999.99.

Welcome to the PSCC Fitness Tracker.

Input file: tracking.prn

Tracking Results

Name Miles

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

Bilbo Baggins 165.9

Rick Grimes 75.4

Zelda Hyrule 23.4

Cindy Arnold 5.1

==================================================

TOTAL 269.8

Thank you for using the PSCC Fitness Tracker.

Use the at least following constants and structure definition for the array of structures.

const int MAX_NAME_LENGTH = 21;

const int MAX_ACTIVITES = 365;

struct Participant {

char firstName[MAX_NAME_LENGTH];

char lastName[MAX_NAME_LENGTH];

double height; // in inches

int numActivities;

int activities[MAX_ACTIVITIES]; // parallel array with

int minutes[MAX_ACTIVITES]; // minutes array

double totalMiles;

};

Other constant examples:

const int NUM_ACTIVITIES = 17;

const int BASKETBALL_GAME = 0;

const int BICYCLING = 1;

etc.

And

const int ACTIVITY_STEPS[NUM_ACTIVITIES] = {242, 242, 61, etc.

so that ACTIVITIES[BASKETBALL_GAME] or ACTIVITIES[participants[i].activities[j]] is 242 (the number of steps for 1 minute of a basketball game) assuming participants[i].activities[j] is a basketball game.

Assume the distance in feet in one persons step, f, is given by the following formula where h is the persons height in inches.

f = (0.413 * h ) /12

Recall there are 5280 feet in a mile.

input.prn is below:

Cindy Arnold 62.5 20 16 45 10 15 17 48 13 12 16 60 17 30 18 45 15 60 16 45 10 10 17 60 18 20 17 45 18 30 15 60 16 60 16 70 17 40 13 16 18 20 Daniel McBride 74 74 16 5 13 1 16 3 13 2 16 5 3 3 16 4 13 1 16 20 13 2 16 5 3 3 16 5 13 1 16 3 13 2 16 5 3 3 16 4 13 1 16 4 13 2 16 20 3 3 16 5 13 1 16 3 13 2 16 5 3 3 16 4 13 1 16 4 13 2 16 30 3 3 6 30 16 5 13 1 16 3 13 2 16 5 3 3 16 4 13 1 16 4 13 2 16 30 3 3 16 5 13 1 16 3 13 2 16 20 3 3 16 4 13 1 16 4 13 2 16 5 3 3 16 5 13 1 16 3 13 2 16 15 3 3 16 4 13 1 16 4 13 2 16 5 3 3 6 30 Nicholas Rajic 67 7 16 30 11 15 16 15 10 10 6 20 11 30 16 35 Dimytri Lyashuk 74 9 17 120 17 120 17 120 17 120 17 120 17 120 0 60 0 60 0 60 Robert Smith 72 4 0 20 13 10 16 60 17 15 Brandon Smith 70 10 17 60 17 60 17 60 17 60 17 60 17 60 17 60 17 60 17 60 17 60 Cameron Fraley 71 19 9 15 9 10 9 10 9 10 14 20 9 15 14 20 9 15 9 15 14 25 15 45 15 45 14 20 15 45 14 20 15 40 9 10 9 10 14 30 Sina Sontowski 66 21 16 15 17 60 16 15 10 45 16 15 17 50 16 15 10 40 16 20 17 60 6 45 16 10 17 45 10 30 16 20 17 60 16 10 10 45 6 30 17 55 6 10 Aman Patel 69 3 10 60 16 90 0 54 Jon Dorsett 75 13 17 107 17 57 17 86 17 77 17 68 17 0 17 52 17 91 17 63 17 74 17 85 17 92 17 67 Michael Wilmouth 72 6 1 200 2 55 6 150 15 240 13 200 16 150 Kishan Patel 67.2 26 1 120 2 50 14 100 15 130 9 300 5 90 14 120 15 180 9 120 2 60 5 80 10 180 14 120 1 60 2 60 2 50 1 120 15 100 14 130 9 300 5 90 10 120 5 50 14 120 1 60 2 60 Sam Harper 72 7 14 120 16 240 14 120 16 210 16 180 16 240 5 300 Noah Kelson 70 4 0 45 2 120 13 55 16 136

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

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

Students also viewed these Databases questions