请编写方法double sumS(int n),该方法计算以下表达式前n项的和S,并返回。
for(int i=1;i<=n;i++){ S=S + flag * fz/fm; temp = fm; fm= fz; fz += temp; flag=flag; } return S;