Advertisement
Guest User

conversion functions

a guest
Oct 6th, 2015
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. enum denomination get_denum(enum denomValue val) {
  2.     /* yeah, this is gonna be some shitty hard coded conversion, if i think of a way and or get time ill make it nice */
  3.    
  4.     if(val == 5) return FIVE_CENTS;
  5.     if(val == 10) return TEN_CENTS;
  6.     if(val == 20) return TWENTY_CENTS;
  7.     if(val == 50) return FIFTY_CENTS;
  8.     if(val == 100) return ONE_DOLLAR;
  9.     if(val == 200) return TWO_DOLLARS;
  10.     if(val == 500) return FIVE_DOLLARS;
  11.     if(val == 1000) return TEN_DOLLARS;
  12.     return NULL;
  13. }
  14.  
  15. enum denomValue get_value(enum denomination den) {
  16.     if (den == FIVE_CENTS) return 5;
  17.     if (den == TEN_CENTS) return 10;
  18.     if (den == TWENTY_CENTS) return 20;
  19.     if (den == FIFTY_CENTS) return 50;
  20.     if (den == ONE_DOLLAR) return 100;
  21.     if (den == TWO_DOLLARS) return 200;
  22.     if (den == FIVE_DOLLARS) return 500;
  23.     if (den == TEN_DOLLARS) return 1000;
  24.     return NULL;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement