← Back to all posts
Calculation

I have a problem with my final code the calculation is wrong and I do not know why this my code:
#include <stdio.h>

int main() {

int child1day = 92;

int child4day = 350;

double taxrate = 0.65;

float total;

int days;

printf("How many children tickets\n");

scanf("%d" ,&child1day);

printf("How many days are they staying ?\n");

scanf("%d", &days);

printf("How many days are you staying ?\n");

scanf("%d" ,&days);

printf("The total cost is \$%.2lf.\n", total*(1+taxrate));

return 0;

}

Voters

I do not program in this language, but from my own stand point, I feel that you are starting to mix up child1day and children1day. I do not know if this will work, but i think you should try changing line 26 to:

`scanf("%d" ,&children1day);`

Do the same with line 34, changing any instance of adult to adults, as well as in line 40.

I hope it works!

mwilki7 (287)

Would you be able to give an example of correct output vs incorrect output?

Dave1 (1)

@mwilki7 a correct output will give right answer for the calculation a wrong one give a wrong answer

mwilki7 (287)

For example, I enter "1 1 1 1" in the program I get:

``````How many children tickets
1
How many days are they staying ?
1