Skip to content

Instantly share code, notes, and snippets.

@johnhmj
Created June 20, 2010 06:51
Show Gist options
  • Save johnhmj/445630 to your computer and use it in GitHub Desktop.
Save johnhmj/445630 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
unsigned int TexiCounter(double distance);
void main(int argc, char** argv)
{
double dis = 0.0;
printf("Input Texi distance: ");
scanf("%lf", &dis);
printf("Money = $%d.-\n", TexiCounter(dis));;
system("PAUSE");
}
unsigned int TexiCounter(double distance)
{
unsigned int nReturn = 100;
if ( distance < 0.0 )
{
distance = 0.0 - distance;
}
if ( distance > 2.0 )
{
distance -= 2.0;
nReturn += ((unsigned int) (distance / 0.5) * 5);
distance -= (unsigned int) distance;
if ( distance > 0.0 )
{
nReturn += 5;
}
}
return nReturn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment