#include<stdio.h>
#include<math.h>

double roundCents(double x);

int main(void)
{
  double input;
  double output;
  printf("enter a number: ");
  scanf("%lf", &input); 
  output = roundCents(input);
  printf("The rounded value is: %f\n",output); 
  return 0;
}

double roundCents(double x)
{
  double y;
  int a,b;
  a = x * 100;
  b = x * 1000;
  y = a / 100.0;
  if(b % 10 >= 5)
    y += 0.01;
  return y;
}

  /*

The old round cents was inprecise with certain floating point numbers, use the one above:

double roundCents(double m)
{
  double x;
  x = m * 100;
  x = floor(x);
  x = x / 100;

  //if m's thousands place is 5 or more
  // add .01 and return the value
  //else return the value I've already computed.

  if(m - x >= 0.005)
  {
	x = x + .01;
  }

  return x;

}
  */
