Hey guys im trying to return the expiry time for a hypathetical car park meter using this program. The parking costs 1.10 per hour im trying to write this function to test this question.
so if i insert 2.00 that should give me a little less then 2 hours how would i calculate that?
Then return the expiry time using a time struct
Im using scanf because its just a test program
Code:#include <stdlib.h> #include <stdio.h> #include <time.h> int parking(time_t *time, float insert); int main(void) { time_t time; int pt; float input; pt = parking(&time, input); return EXIT_SUCCESS; } int parking(time_t *time, float insert) { float parkingCost = 1.10; float expire = 0.00; scanf("%f", &insert); if(insert < parkingCost) { printf("You have inserted money for less then an hour\n"); return 0; } else if(insert > parkingCost) { printf("You have inserted money past the hour\n"); expire = insert + parkingCost; } printf("%f", expire); return expire; }



LinkBack URL
About LinkBacks


