Im still having some problems with the time, I used some test data to test the formula, and these are the results I get.
14: 22 Out
12: 40 In
------------
and I get 2.68 as the answer, instead of 1.42.
I also tested:
8 : 40 Out
8 : 20 In
------------
And I got 1. 20 instead of .20
This is the output I got after entering it into the program, also Im not sure why everything is printing out, it should only print one statement, instead it prints out both truck and bus:
Code:
Type of vehicle?
c
Hour vehicle entered lot?
8
Minute vehicle entered lot?
20
Hour vehicle left lot?
8
Minute vehicle left lot?
40
1 : 20<---- This time spent in parking lot
PARKING LOT CHARGE
Type of Vehicle: Car
TIME-IN 8 : 20
TIME-OUT 8 : 40
--------
PARKING TIME 1 :1
ROUNDED TOTAL 0
--------
TOTAL CHARGE $ 0.000000
PARKING LOT CHARGE
Type of Vehicle: Truck
TIME-IN 8 : 20
TIME-OUT 8 : 40
--------
PARKING TIME 1 :20
ROUNDED TOTAL 0
--------
TOTAL CHARGE $ 1.000000
PARKING LOT CHARGE
Type of Vehicle: Bus
TIME-IN 8 : 20
TIME-OUT 8 : 40
--------
PARKING TIME 1 :20
ROUNDED TOTAL 0
--------
TOTAL CHARGE $ 2.000000
Press any key to continue
Here's how I coded it:
Code:
/* This program is created by: A Frustrated Programmer
*/
#include <stdio.h>
int main (void)
{
/* Local Definitions */
char vec;
int hrIn;
int hrOut;
int minIn;
int minOut;
int min;
int hour;
float fee;
int round;
/* Statements */
printf("Type of vehicle?\n");
scanf("%c", &vec);
printf("Hour vehicle entered lot?\n");
scanf("%d", &hrIn);
printf("Minute vehicle entered lot?\n");
scanf("%d", &minIn);
printf("Hour vehicle left lot?\n");
scanf("%d", &hrOut);
printf("Minute vehicle left lot?\n");
scanf("%d", &minOut);
/* Time Calculations */
min = (60* (hrOut - hrIn)) + (minOut - minIn);
/* Round Up Time */
hour = (float)(min + 59) / 60;
/* Print Check to see if Time is Correct */
printf("%d : %d\n", hour, min);
/* Tow */
if (hour >= 24)
printf("Tow");
/* Conditions */
if(vec = 'c')
if(hour <= 3)
{
fee = 0.00;
printf("\n\t\tPARKING LOT CHARGE\n\n\t\tType of Vehicle: Car\n\t\tTIME-IN\t\t\t%d : %d\n\t\tTIME-OUT\t\t%d : %d\n\t\t\t\t\t--------\n\n\t\tPARKING TIME\t\t%d :%d\n\t\tROUNDED TOTAL\t\t\t%d\n\t\t\t\t\t--------\n\t\tTOTAL CHARGE\t\t$ %f\n", hrIn,minIn, hrOut, minOut,hour, hour, fee);
}
else
{
fee = (hour - 3) * 1.50;
printf("\n\t\tPARKING LOT CHARGE\n\n\t\tType of Vehicle: Car\n\t\tTIME-IN\t\t\t%d : %d\n\t\tTIME-OUT\t\t%d : %d\n\t\t\t\t\t--------\n\n\t\tPARKING TIME\t\t%d :%d\n\t\tROUNDED TOTAL\t\t\t%d\n\t\t\t\t\t--------\n\t\tTOTAL CHARGE\t\t$ %f\n", hrIn,minIn, hrOut, minOut,hour, min, hour, fee);
}
if(vec = 't')
if (hour <= 2)
{
fee = hour * 1.00;
printf("\n\t\tPARKING LOT CHARGE\n\n\t\tType of Vehicle: Truck\n\t\tTIME-IN\t\t\t%d : %d\n\t\tTIME-OUT\t\t%d : %d\n\t\t\t\t\t--------\n\n\t\tPARKING TIME\t\t%d :%d\n\t\tROUNDED TOTAL\t\t\t%d\n\t\t\t\t\t--------\n\t\tTOTAL CHARGE\t\t$ %f\n", hrIn,minIn, hrOut, minOut,hour, min, hour, fee);
}
else
{
fee = ((hour - 2.00) * 2.30) + 2.00;
printf("\n\t\tPARKING LOT CHARGE\n\n\t\tType of Vehicle: Truck\n\t\tTIME-IN\t\t\t%d : %d\n\t\tTIME-OUT\t\t%d : %d\n\t\t\t\t\t--------\n\n\t\tPARKING TIME\t\t%d :%d\n\t\tROUNDED TOTAL\t\t\t%d\n\t\t\t\t\t--------\n\t\tTOTAL CHARGE\t\t$ %f\n", hrIn,minIn, hrOut, minOut,hour, min, hour, fee);
}
if(vec = 'b')
if(hour <= 1)
{
fee = hour * 2.00;
printf("\n\t\tPARKING LOT CHARGE\n\n\t\tType of Vehicle: Bus\n\t\tTIME-IN\t\t\t%d : %d\n\t\tTIME-OUT\t\t%d : %d\n\t\t\t\t\t--------\n\n\t\tPARKING TIME\t\t%d :%d\n\t\tROUNDED TOTAL\t\t\t%d\n\t\t\t\t\t--------\n\t\tTOTAL CHARGE\t\t$ %f\n", hrIn,minIn, hrOut, minOut,hour, min, hour, fee);
}
else
{
fee = ((hour - 1.00) * 3.70) + 2.00;
printf("\n\t\tPARKING LOT CHARGE\n\n\t\tType of Vehicle: Bus\n\t\tTIME-IN\t\t\t%d : %d\n\t\tTIME-OUT\t\t%d : %d\n\t\t\t\t\t--------\n\n\t\tPARKING TIME\t\t%d :%d\n\t\tROUNDED TOTAL\t\t\t%d\n\t\t\t\t\t--------\n\t\tTOTAL CHARGE\t\t$ %f\n", hrIn,minIn, hrOut, minOut,hour, min, hour, fee);
}
/* end if */
return 0;
}
/* main */
/* Results: */