C Programming - Having difficulty with this program?
As I am writing this code, I have it set up where I can input values, but I am having difficulty with the math part. Do I have to put in "#define" and that formula before the "int main(void)" and insert the equation before the getch()? I know I have to tell the program that a is this, g is that, etc, but that is where I am stuck at. Here is the question and what I have so far is at the bottom:
Prompt the user to enter the following values:
1. Time of Day (hour from 0-23, in military time, let this be t)
2. Parking Spots Available (for the semester, let this be a)
3. Parking Permits Given (for the semester, let this be g)
After much observation, you have realized that the formula for determining the amount of time you will wait to get a parking spot is:
Time (in minutes) = (12 – | 12 – t |)*g/a
1. The time of day will be a single integer in between 0 and 23, inclusive, representing the hour the user is attempting to park.
2. This number of spots available will be a positive integer less than 50,000.
3. The number of permits given will be a positive integer less than 60,000.
What hour are you looking for parking?
How many spots are available this semester?
How many parking permits were given this semester?
You will have to wait 50.00 minutes to find parking.
(MY WORK SO FAR)
int hour, spots, parking_permits;
printf ("What hour are you looking for parking? \n");
scanf ("%d", &hour);
printf ("How many spots are available this semester? \n");
scanf ("%d", &spots);
printf ("How many parking permits were given this semester? \n");
scanf ("%d", &parking_permits);