int sum = 0; mistake
Replace with:
Double sum = 0.0;
Think about why (totPjz=sum/totCnt)? In addition, if you feel smart, the previous changes are as follows:
totPjz =(double)sum/tot CNT;
This is also wrong. Think again why (the storage capacity of int and double)?