You don't assign values outside of the if statements ... and it is possible that credit might be something other than 0, 1, 2, or 3, as @iomaxx noted.
Try changing the separate if statements to a single if/else if/else if/else. Or assign default values up at the top.