``````#include <stdio.h>

#define CALORIES 150
#define  WEIGHT 15

int main()
{
double beer;
double money_spent;
double total_spent;
double total_beer_consumed;
double total_calories_consumed;
double weight_gain;

printf("On average, how many beers will you consume each day?\n");
scanf("%lf\n", &beer);

printf("On average, how much will you pay for each can of beer?\n");
scanf("%lf\n", &money_spent);

// CALCULATIONS

total_beer_consumed = beer *365; // total beer consumed the whole year
printf("That is approximately %.2lf beers in one year.\n", &total_beer_consumed);

total_calories_consumed = beer * CALORIES; // total calories consumed
printf("In one year, you will consume approximately  %.2lf calories from beer alone.\n", &total_calories_consumed);

weight_gain = beer * WEIGHT; // total weight gained throughout the whole year
printf("Without diet or exercise to counter these calories, you can expect");
printf("to gain %.2lf pounds from drinking that much beer this year.\n", &weight_gain);

total_spent = (beer * money_spent)*365; // money spent on beer this year
printf("You will spend approximately %.2lf on beer this year.\n", &money_spent);

system("pause");
return 0;
}``````

this is what i want the program to do,
On average, how many beers will you consume each day?
2.5
On average, how much will you pay for each can of beer?
1.25
That is approximately 912.50 beers in one year.
In one year, you will consume approximately 136875.00 calories from beer alone.
Without diet or exercise to counter these calories, you can expect to gain 37.50 pounds from drinking that much beer this year.
You will spend approximately \$1140.62 on beer this year.

BUT when it asks on the 1st questions it asks me to put in two values before asking the second question

and the calculations dont work

3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by gman1991

Take the '\n' out of your scanf format specifiers.

still when i compile and run the code, no calculations are performed

You're printing the addresses of variables rather than the values. scanf and printf are not the same.

i have already sorted it thank you

i figured it was because of i put & in front of the variables in the print statements of the

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.