when i run the program it skips the Int Tax(); function an i tried changing it to void an taking out return 0; but its still not working

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.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 vehicle left the parking lot
int hr; //final hour
int min; //final minute
int minutes_max;//60 minutes
int hours_max;//24 hours
hrsn=0;
hrso=0;
minn=0;
mino=0;
hr=0;
min=0;
minutes_max=0;
hours_max=0;
int Tax();

void 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(minn < mino)
{
  minutes_max = 60 - (mino - minn);
  //minutes_max = 60 - 5
  //minutes_max = 55 minutes
}
else if(minn > mino)
{
     minutes_max = (60 - minn) + mino;
     hrso = hrso-1;
}

else

  minutes_max = 0; //minutes_in equals minutes_out


if (hrsn < hrso)
{
    hours_max = 24 - (hrso - hrsn);
}

else if (hrsn > hrso)
{
    hours_max = (24 - hrso) + hrsn;
}

else
hours_max = 0;


hours_max = (hrso - hrsn);


printf("Time in %d:%d\n", hrsn, minn);
printf("Parking Time:  %d:%d \n", hours_max, minutes_max);

}


}

int Tax()
{

float gct;
float price_car;
float price_truck;
float price;
float finalprice;
price=0;
finalprice=0;
gct=0.175; //17.5%
price_car=0;
price_truck=0;



if(vehicle == "car")
{

if( minutes_max > 1 || minutes_max < 30)
{
    price = price_car + 50;
}
else if(minutes_max > 30 || minutes_max < 60)
{
    price = price_car + 100;
}
else if( hours_max >= 1)
{
    price = (price_car+100) * hours_max;
}

finalprice = (gct * price) + price;

}

if(vehicle == "truck")
{

if( minutes_max > 1 || minutes_max < 30)
{
    price = price_truck + 50;
}
else if(minutes_max > 30 || minutes_max < 60)
{
    price = price_truck + 100;
}
else if( hours_max >= 1)
{
    price = (price_truck+100) * hours_max;
}

finalprice = (gct * price) + price;

}

printf("The Final Price is: %f", finalprice);
return 0;
}

Recommended Answers

All 6 Replies

Where do you call the function Tax()? Certainly, no where.

Here's an example of how it works

#include <stdio.h>

int special_function(); /* Here is my card, call me if you need me */


int main (void) /* notice that it is not void main */
{
    int mywallet = 0; /* My wallet too */

    mywallet = special_function(); /* I need to call that nice special_function */
    printf("Thank you for the $%d\n", mywallet);

    return EXIT_SUCCESS; /* return control to host OS */
}

/* Here's where special_function lives */
int special_function()
{
    int money = 200; /* $$ */
    printf("I am a very special function\n");
    return money; /* I am giving you $200 */
}

i didnt see that u posted a code but i used pointer last yr for a similar problem but its not working

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.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 vehicle left the parking lot
int hr; //final hour
int min; //final minute
int minutes_max;//60 minutes
int hours_max;//24 hours
hrsn=0;
hrso=0;
minn=0;
mino=0;
hr=0;
min=0;
minutes_max=0;
hours_max=0;

void Tax(float *gct, float *price_car, float *price_truck, float *price, float *finalprice);

int main(void)

{

float gct;
float price_car;
float price_truck;
float price;
float finalprice;
price=0;
finalprice=0;
gct=0.175; //17.5%
price_car=0;
price_truck=0;

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(minn < mino)
{
  minutes_max = 60 - (mino - minn);
  //minutes_max = 60 - 5
  //minutes_max = 55 minutes
}
else if(minn > mino)
{
     minutes_max = (60 - minn) + mino;
     hrso = hrso-1;
}

else

  minutes_max = 0; //minutes_in equals minutes_out


if (hrsn < hrso)
{
    hours_max = 24 - (hrso - hrsn);
}

else if (hrsn > hrso)
{
    hours_max = (24 - hrso) + hrsn;
}

else
hours_max = 0;


hours_max = (hrso - hrsn);


printf("Time in %d:%d\n", hrsn, minn);
printf("Parking Time:  %d:%d \n", hours_max, minutes_max);

}



Tax(&gct,&price_car,&price_truck,&price,&finalprice);


}


void Tax(float *gct, float *price_car, float *price_truck, float *price, float *finalprice)
{

if((strcmp(vehicle, "car")) == 0)
{

if( minutes_max > 1 || minutes_max < 30)
{
    price = price_car + 50;
}
else if(minutes_max > 30 || minutes_max < 60)
{
    price = price_car + 100;
}
else if( hours_max >= 1)
{
    price = (price_car+100) * hours_max;
}

finalprice = (gct * price) + price;

}

if((strcmp(vehicle, "truck")) == 0)
{

if( minutes_max > 1 || minutes_max < 30)
{
    price = price_truck + 50;
}
else if(minutes_max > 30 || minutes_max < 60)
{
    price = price_truck + 100;
}
else if( hours_max >= 1)
{
    price = (price_truck+100) * hours_max;
}

finalprice = (gct * price) + price;

}

printf("The Final Price is: %f", finalprice);
return 0;
}

I answered this question for you, in the other forum.

Now that you're cross posting, I won't bother henceforth. You're wasting our time.

I didn't even know there was something wrong with cross posting and i came over here because after a while no one was responding to my posts, so sorry if i offended u in any way.
I carried over minutes_max , hours_max and vehicle and it runs now but it crashes when i input the last variable for the main() part of the program

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.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 vehicle left the parking lot
int hr; //final hour
int min; //final minute
int minutes_max;//60 minutes
int hours_max;//24 hours
hrsn=0;
hrso=0;
minn=0;
mino=0;
hr=0;
min=0;
minutes_max=0;
hours_max=0;

void Tax(float *gct, float *price_car, float *price_truck, float *price, float *finalprice, int *minutes_max, int *hours_max, char *vehicle[5]);

int main(void)

{

float gct;
float price_car;
float price_truck;
float price;
float finalprice;
price=0;
finalprice=0;
gct=0.175; //17.5%
price_car=0;
price_truck=0;

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(minn < mino)
{
  minutes_max = 60 - (mino - minn);
  //minutes_max = 60 - 5
  //minutes_max = 55 minutes
}
else if(minn > mino)
{
     minutes_max = (60 - minn) + mino;
     hrso = hrso-1;
}

else

  minutes_max = 0; //minutes_in equals minutes_out


if (hrsn < hrso)
{
    hours_max = 24 - (hrso - hrsn);
}

else if (hrsn > hrso)
{
    hours_max = (24 - hrso) + hrsn;
}

else
hours_max = 0;


hours_max = (hrso - hrsn);


printf("Time in %d:%d\n", hrsn, minn);
printf("Parking Time:  %d:%d \n", hours_max, minutes_max);

Tax(&gct,&price_car,&price_truck,&price,&finalprice,&minutes_max,&hours_max,&vehicle[5]);


}


void Tax(float *gct, float *price_car, float *price_truck, float *price, float *finalprice, int *minutes_max, int *hours_max, char *vehicle[5])
{

if((strcmp(*vehicle, "car")) == 0)
{

if( *minutes_max > 1 || *minutes_max < 30)
{
    *price = *price_car + 50;
}
else if(*minutes_max > 30 || *minutes_max < 60)
{
    *price = *price_car + 100;
}
else if( *hours_max >= 1)
{
    *price = (*price_car+100) * *hours_max;
}

*finalprice = (*gct * *price) + *price;

}

if((strcmp(*vehicle, "truck")) == 0)
{

if( *minutes_max > 1 || *minutes_max < 30)
{
    *price = *price_truck + 50;
}
else if(*minutes_max > 30 || *minutes_max < 60)
{
    *price = *price_truck + 100;
}
else if( *hours_max >= 1)
{
    *price = (*price_truck+100) * *hours_max;
}

*finalprice = (*gct * *price) + *price;

}

printf("The Final Price is: %f", *finalprice);

}

i fixed that part but the calculations for final price are showing me zero

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>


void Tax(float *gct, int *price_car, int *price_truck, int *price, float *finalprice, int *minutes_max, int *hours_max, char *vehicle[5]);

int main(void)

{

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 vehicle left the parking lot
int hr; //final hour
int min; //final minute
int minutes_max;//60 minutes
int hours_max;//24 hours
hrsn=0;
hrso=0;
minn=0;
mino=0;
hr=0;
min=0;
minutes_max=0;
hours_max=0;
int price=0;
float finalprice=0;
float gct=0.175; //17.5%
int price_car=0;
int price_truck=0;


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(minn < mino)
{
  minutes_max = 60 - (mino - minn);
  //minutes_max = 60 - 5
  //minutes_max = 55 minutes
}
else if(minn > mino)
{
     minutes_max = (60 - minn) + mino;
     hrso = hrso-1;
}

else

  minutes_max = 0; //minutes_in equals minutes_out


if (hrsn < hrso)
{
    hours_max = 24 - (hrso - hrsn);
}

else if (hrsn > hrso)
{
    hours_max = (24 - hrso) + hrsn;
}

else
hours_max = 0;


hours_max = (hrso - hrsn);


printf("Time in %d:%d\n", hrsn, minn);
printf("Parking Time:  %d:%d \n", hours_max, minutes_max);

Tax(&gct,&price_car,&price_truck,&price,&finalprice,&minutes_max,&hours_max,&vehicle[5]);


}


void Tax(float *gct, int *price_car, int *price_truck, int *price, float *finalprice, int *minutes_max, int *hours_max, char *vehicle[5])
{

while((strcmp(*vehicle, "car")) == 0)
{
if( *minutes_max > 1 || *minutes_max < 30)
{
    *price = *price_car + 50;
}
else if(*minutes_max > 30 || *minutes_max < 60)
{
    *price = *price_car + 100;
}
else if( *hours_max >= 1)
{
    *price = (*price_car+100) * *hours_max;
}

*finalprice = (*gct * *price) + *price;


if((strcmp(*vehicle, "truck")) == 0)
{

if( *minutes_max > 1 || *minutes_max < 30)
{
    *price = *price_truck + 50;
}
else if(*minutes_max > 30 || *minutes_max < 60)
{
    *price = *price_truck + 100;
}
else if( *hours_max >= 1)
{
    *price = (*price_truck+100) * *hours_max;
}

*finalprice = (*gct * *price) + *price;

}
}
printf("The Final Price is: %f", *finalprice);

}

the calulations for the final price is still messed up need assistance plz

#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>

void Tax(float *gct, int *price_car, int *price_truck, int *price, float *finalprice, int *minutes_max, int *hours_max, char *vehicle);

int main(void)
{
  char vehicle[6];
  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 vehicle left the parking lot
  int hr; //final hour
  int min; //final minute
  int minutes_max;//60 minutes
  int hours_max;//24 hours
  int price;
  int price_car;
  int price_truck;
  int i, length;
  float finalprice;
  float gct;
  hrsn=0;
  hrso=0;
  minn=0;
  mino=0;
  hr=0;
  min=0;
  minutes_max=0;
  hours_max=0;
  price=0;
  finalprice=0;
  gct=0.175; //17.5%
  price_car=0;
  price_truck=0;

  printf("\n\nWhere 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);
  }
  length = strlen(vehicle);
  for (i=0; i<length; i++)
  { //change all vehicle letters to lowercase
    vehicle[i] = tolower(vehicle[i]);
  }

  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(minn < mino)
  {
    minutes_max = mino - minn;
    //minutes_max = 60 - 5
    //minutes_max = 55 minutes
  }
  else if(minn > mino)
  {
     minutes_max = (60 - minn) + mino;
     hrso = hrso-1;
  }
  else
  {
     minutes_max = 0; //minutes_in equals minutes_out
  }
  if (hrsn < hrso)
  {
    hours_max = 24 - (hrso - hrsn);
  }
  else if (hrsn > hrso)
  {
    hours_max = (24 - hrso) + hrsn;
  }
  else
  {
    hours_max = 0;
  }
  hours_max = (hrso - hrsn);
  printf("Time in %d:%d\n", hrsn, minn);
  printf("Parking Time:  %d hours:%d minutes\n", hours_max, minutes_max);

  Tax(&gct,&price_car,&price_truck,&price,&finalprice,&minutes_max,&hours_max,vehicle);
  return 0;
}
void Tax(float *gct, int *price_car, int *price_truck, int *price, float *finalprice, int *minutes_max, int *hours_max, char *vehicle)
{
  if((strcmp(vehicle, "car")) == 0)
  {
    printf("The price for the car will be shown shortly:\n");
    if( *minutes_max>1 || *minutes_max<30)
    {
      *price=*price_car+50;
    }
      else if(*minutes_max>30 || *minutes_max<60)
    {
      *price=*price_car+100;
    }
    else if(*hours_max>=1)
    {
      *price=(*price_car+100)**hours_max;
    }
    *finalprice=(*gct**price)+*price;
    printf("The Final Price is: %f\n", *finalprice);
  }
  else
  //if((strcmp(vehicle, "truck")) == 0)
  {
    printf("The Price for the truck will be shown shortly\n");
    if( *minutes_max > 1 || *minutes_max < 30)
    {
      *price = *price_truck + 100;
    }
    else if(*minutes_max > 30 || *minutes_max < 60)
    {
      *price = *price_truck + 150;
    }
    else if( *hours_max >= 1)
    {
      *price = (*price_truck+200) * *hours_max;
    }
    *finalprice = (*gct * *price) + *price;
    printf("The Final Price is: %f\n", *finalprice);
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.