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 <stdio.h>

#include <math.h>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;

}

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...

Rather a lot of parentheses there. Try this int 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.

Then

weeks = days/7

days = 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

to lose or gain 1 lb =3500 calories

Ask Your Question

Weekly Poll

Do you think Google should sell budget phones in the US?

Discuss in The Lounge

Poll History