You're using all ints, so all calculations are going to be ints. That means that any decimals are going to be dropped. You might want to use floats or doubles instead.