Modify char count to use double and for loop