# Having trouble writing a formula

• 09-05-2009
Neotriz
Having trouble writing a formula
I have this homework assigned for my programming class and I'm having trouble writing the following formula:

Time (in minutes) = (12 – | 12 – t |)*g/a

where t is equal to the time of day (in military time)
a is equal to parking spots availabe
and g is equal to parking permits given

Code:

``` #include<stdio.h>   int main () {             int t, a, g;       double total_time_to_wait;             printf("What hour are you looking for parking?\n");       scanf("%d", &t);             printf("How many sports are availabe this semester?\n");       scanf("%d", &a);             printf("How many parking permits were given this semester?\n");       scanf("%d", &g);             total_time_to_wait= (12-|(12-t)|)*(g/a);       printf("You will have to wait %.2lf to find parking.", total_time_to_wait);             system("PAUSE");       return 0;             }```

Not really sure if I'm writing the right way
• 09-05-2009
Neotriz
EDIT: the second question should be "How many spots..."
• 09-05-2009
Neotriz
never mind, problem solved