Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You made your 10,000 steps for today! But is it enough? Suppose someone wanted t

ID: 3843749 • Letter: Y

Question

You made your 10,000 steps for today! But is it enough? Suppose someone wanted to lose two pounds a week until they reached their desired weight. Would 10,000 steps be enough? And what if they only completed 10,000 five days out of the week? That would actually be an average of 7, 143 steps per day for the week. Multiple by 7 to get the total weekly steps. Assume that each person needs to walk 2,000 steps to reach 1 mile. Use a factor of 0.57 as the calories burned per mile when a person walks at a casual pace. An individual would need to burn 3500 calories to lose one pound. The formula for calculating the pounds lost per week would be: weight * totalWeeklySteps * (factor/steps per mile) caloresPerPound Write a program the inputs a name, weight, and average daily steps for the week from a text file. There are sixteen walkers in the file. The program will then determine if the each person is on target to lose two pounds for the week (assuming all else the same in the person's life-no increase in other exercise or reduction in calorie input). Remember, we are looking for the weekly average pounds-The file contains the daily average steps. The program will output a list of only the people who are on target. Use a method to calculate pounds lost each week from steps. Input: text file (walkers.txt) Sample output: Earl is on target to lose two pounds a week. ... Ray is on target to lose two pounds a week. Everyone else needs to walk more.

Explanation / Answer

#include<stdio.h>
#define FACTOR 0.57
#define SPM 7143
#define CALPM 3500

double calcWeightLoss(double weeklyAvg, int weight) {
   return double result = weight * weeklyAvg * (FACTOR/SPM)/CALPM;
}

int main() {
   FILE *fp = fopen("walkers.txt", "r");
   int dailySum;
   double weeklyAvg;
   int weight;
   char name[20];
   int i, tmp;
   while (!feof(fp)) {
       fscanf(fp, "%s %d",name, &weight);
       for (i=0; i<7; i++) {
           fscanf(fp, "%d", &tmp); //read weight and store in tmp
           dailySum += tmp;//add the weight
       }
       weeklyAvg = (double) dailySum/7; //get avh of 7weights
       if ( calcWeightLoss(weeklyAvg, weight) >= 2) //caclulate weight loss
           printf("%s is on target to loose two pounds a week ",name);
   }
    printf("Everyone else needs to work hard");
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote