统计信息

  • 访问数:8706
  • 博客数:142
  • 建立时间:2008-01-05
  • 更新时间:2008-05-21
我叫王超然,是一名电脑爱好者,现在在新加坡留学上高一.我立志成为一名电脑人才,愿意在这里与大家一同分享我玩转电脑的心得.O-level华文考了A-One哈哈!

P5Q11

2008-04-09 09:02:54

天气: 晴朗 心情: 高兴

/*fileName:P5Q11.java
*Name:Wang Chaoran
* Description:
11 (Summing series)
Write a method to compute the following series:
Write a test program that displays the following table:
i m(i)
2 0.5
3 1.1667
...
19 15.4523
20 16.4023

*/
public class P5Q11{
  public static void main(String[] args){
    System.out.println("i       m(i)");
    for(int i=2;i<=20;i++){
      System.out.print(i+"     ");
      if(i<10)
        System.out.print(" ");
      System.out.printf("%-6.4f",m(i));
      System.out.println();
    }
  }
  public static double m(int i){
  double sum=1;
  for(double j=2;j<=i;j++){
        sum += -1/(2*j-1)+1/(2*j+1);
  }
  return sum*4;
}
}


加入收藏 编辑 审核

TAG: computing

我来说两句

OPEN

Powered by X-Space 1.2 © 2001-2006 Comsenz Technology Ltd