# Calorie Counter. STUCK coding

May 28, 2011 at 10:35:13
Specs: Windows 7
 I need to print out the number of weeks and days it will take to get to goal weight.I'm able to get the program to run correctly and calculate the number of weeks but then I'm stuck on what to do to get the # of days (I guess it's thinking of days like a remainder of weeks)? I'm not sure what to do I suck at this. //5/28/11//Assignment 1//Part C: Weight Calculations#include #include int main() { //Program starts here int weight,goal_weight,calories; //Prompt for and read in user input. printf("What is your current weight (in pounds)? \n", weight); scanf("%d", &weight); printf("What is your goal weight (in pounds)? \n", goal_weight); scanf("%d", &goal_weight); printf("How many calories do you typically burn on an average day? \n", calories); scanf("%d", &calories); //Calculate and print out the time until goal weight is met. int weeks= ((((weight-goal_weight)*(3500.0))/(calories))/(7.0)); printf("You should meet your goal weight in %d weeks and %d days ! \n", weeks); system("PAUSE"); return 0; }

See More: Calorie Counter. STUCK coding

#1
May 28, 2011 at 10:42:43
 I found a way to get the program to run accurately but I doubt I will get credit for this one lol.For calculating the days I inserted: int days= (((weight-goal_weight)*(35.0))/(calories));scratch that. It only works for one of the sample runs...

Report •

#2
May 28, 2011 at 13:53:12
 Rather a lot of parentheses there. Try thisint days= ((weight-goal_weight)*35.0)/calories;In this formulas weight-goal_weight is calculated. The result of that is multiplied by 35 and finally the result of that is divided by calories.Thenweeks = days/7days = fmod(days,7)I have no idea where the 35.0 or 35000.0 come into it. I imagine that is some constant to do with weight calculations.Stuart

Report •

#3
May 28, 2011 at 17:10:07
 to lose or gain 1 lb =3500 calories

Report •

Related Solutions