Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I am to write a program in c++ that emulates a fitness log. instead of recieving input from a tracker, the data is recieved

Hello, I am to write a program in c++ that emulates a fitness log. instead of recieving input from a tracker, the data is recieved from an input.prn. 19 total activites each assigned with their own code, and the number of steps given in 1 minute. Like so,

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

The input file lists the first name, last name, height in inches, followed by the number of activities on the next lines. So for example, below is a sample input. A1 is first name, B1 is last name, C1 is the person's height, and D1 is the number of activities the individual did. A2 is coded for walking, and B2 is how long the activity was performed.

Bob Smith 62.5 3
14 45
9 15
16 45

The Program asks 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.

The program prints a welcome message then reads the file into an array of structures (assuming the file exists and is non-empty;

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.

The following constants and structure definition for the array of structures must follow

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;

};

Any Help is appreciated. This is a review for my class and my skill are quite rusty. Thank you.

The input.prn file looks as following, negating any space.

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 6

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

Determine the amplitude and period of each function.

Answered: 1 week ago