Thx very much it works like a charm do u know of a better way for the time part of my program cause im gonna need something easier to use and i read up on time.h that sounds like it mostly gives me the current time on my pc and not something that makes the users input their time to manipulate it. Its necessary cause im gonna add on a tax function ni my program for different parking times.
Code:#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
char vehicle[5];
int car;
int truck;
int hrsn; //Hour the vehicle entered the parking lot
int minn; //Minute the vehicle came in the parking lot
int hrso; //Hour the vehicle left the parking lot
int mino; //Minute the vehivle left the parking lot
int hr; //final hour
int min; //final minute
hrsn=0;
hrso=0;
minn=0;
mino=0;
hr=0;
min=0;
int main()
{
printf("Where you driving a car or truck?\n");
scanf("%s", &vehicle );
while( strcmp( vehicle, "truck" ) != 0 && strcmp( vehicle, "car" ) != 0 )
{
printf("Please input the words Car or Truck: ");
scanf("%s",&vehicle);
}
printf("What Hour did the %s enter the lot? (0-23)\n", vehicle);
scanf("%d",&hrsn);
while((hrsn<0 || hrsn>23))
{
printf("\a\a\a Please Input Value from 0-23!\n");
scanf("%d",& hrsn);
}
{
printf("What Minute did the %s enter the lot? (0-59)\n", vehicle);
scanf("%d",& minn);
}
while((minn<0 || minn>59))
{
printf("\a\a\a Please Enter Correct Minute Between 0-59!\n");
scanf("%d",& minn);
}
{
printf("What Hour did the %s leave the lot? (0-23)\n", vehicle);
scanf("%d",& hrso);
}
while((hrso<0 || hrso>23))
{
printf("\a\a\a Please Enter the Correct Time Between 0-23!\n");
scanf("%d",& hrso);
}
{
printf("What Minute did the %s leave the lot? (0-59)\n", vehicle);
scanf("%d",& mino);
}
while(mino<0 || mino>59)
{
printf("\a\a\a PLease Enter the Correct time between 0-59!\n");
scanf("%d",& mino);
}
{
if (hrsn < (hrso - 1) && minn > mino)
{
hrso = hrso - 1;
mino = mino + 60;
}
if (mino - minn > 1 && mino - minn < 30)
{
mino = minn+30;
}
else if (mino - minn > 30 && mino - minn < 60)
{
mino = minn + 60;
}
else
{
mino = minn + 00;
}
hr = (hrso-hrsn);
min = (mino - minn);
printf("Time in %d:%d\n", hrsn, minn);
printf("Parking Time %d hours:%d minutes\n", hr, min);
}
return 0;
}