# I think my calculation is wrong

This is a discussion on I think my calculation is wrong within the C Programming forums, part of the General Programming Boards category; I'm continuing to work on this water billproject of mine and its going well but I think my calculation is ...

1. ## I think my calculation is wrong

I'm continuing to work on this water billproject of mine and its going well but I think my calculation is wrong. Here's the code:

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

int main()

{
int		customernumber;
float	waterlevel;
float	previouslevel;
float	totalwater;
float	totalbill;
float	amountowed;

printf("Enter customer number\n" );

scanf( "%d" ,  &customernumber );

printf("Enter current water level\n" );

scanf("%f" , &waterlevel );

printf("Enter previous water level\n" );

scanf("%f", &previouslevel );

totalwater = waterlevel - previouslevel;

totalbill = totalwater/1000  * .55f;

printf("The total bill is %f\n", &amountowed );```
No matter what numbers I input I get 0.0000 for the totalbill, once again I'm at a loss as to why.
Any feedback is more then appreciated,
thank you so much.
-Extro
Edit: Sorry I forgot to post the final line of code.

2. What are the values you are using for input? Where is the line of code that outputs the bill?

3. The amount entered should be any number in the thousands and I get a monetary result.
Thanks,
Extro

4. I meant what specific values were you using but that doesn't matter now because I know what's going on with your code... see below.

Originally Posted by Extropian
I'm continuing to work on this water billproject of mine and its going well but I think my calculation is wrong. Here's the code:

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

int main()
{
int   customernumber;
float waterlevel;
float previouslevel;
float totalwater;
float totalbill;
float amountowed;

printf("Enter customer number\n" );
scanf( "%d" ,  &customernumber );

printf("Enter current water level\n" );
scanf("%f" , &waterlevel );

printf("Enter previous water level\n" );
scanf("%f", &previouslevel );

totalwater = waterlevel - previouslevel;

totalbill = totalwater/1000  * .55f;

printf("The total bill is %f\n", &amountowed );```
No matter what numbers I input I get 0.0000 for the totalbill, once again I'm at a loss as to why.
Any feedback is more then appreciated,
thank you so much.
-Extro
Edit: Sorry I forgot to post the final line of code.
You aren't giving amountowed a value anywhere beyond what it starts out with. You calculate totalbill but try to print out something else entirely. Did you mean to print out totalbill instead? Also, don't use the & in front of values you are printing out.

5. Ok thank you, one more quick more questions if thats ok (I know all about the howework rule and I agree with it, so i hope I'm not asking too much).
My question is,
How do I get his to read out in dollars?
Thanks again.

6. Code:
```#include <stdio.h>

int main()
{
double amount = 1.1;
printf("amount = \$%.2f\n", amount);
return 0;
}

/* my output
amount = \$1.10
*/```

7. > printf("The total bill is %f\n", &amountowed );
1. Remove the & - this is printf, not scanf
2. Get a compiler (eg. gcc) which will tell you when you make dumb mistakes with printf and scanf.

8. One last question:

I want to say if amount is greater than 5000 but less than or equal to 75000 how would I do that?
I think the code would look somewhat like this:
Code:
``` if (amountowed > 5000 <= 75000)
{
totalbill = totalbill * .2f;
}```
this is obviously wrong, I'm just not sure what that condition should look like.
Thanks a bunch
-Extro

9. Code:
`if ( amountowed > 5000 && amountowed <= 75000 )`

10. Well I finished that program, thank for all the help everyone.