统计信息

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

P5Q17

2008-04-09 10:25:28

天气: 晴朗 心情: 高兴

/*fileName:P5Q17.java
*Name:Wang Chaoran
* Description:
17 (Using trigonometric methods)
Print the following table to display the sin value and cos value of
degrees from 0 to 360 with increments of 10 degrees. Round the value to keep four digits after the decimal point.
Degree     Sin     Cos
0          0.0     1.0
10         0.1736  0.9848
...
350       -0.1736  0.9848
360        0.0     1.0
*/
public class P5Q17{
  public static void main(String[] args){
    System.out.println("Degree     Sin     Cos");
    for(int i=0;i<=360;i+=10){
    System.out.print(i+"     ");
    if(i<100)
      System.out.print("  ");
    if(i<10)
      System.out.print(" ");
    System.out.printf("%-6.4f",Math.sin(Math.toRadians(i)));
    if(Math.sin(i)>=0)
      System.out.print(" ");
    System.out.print("  ");
    System.out.printf("%-6.4f",Math.cos(Math.toRadians(i)));
    System.out.println();
    }
    }
  }

加入收藏 编辑 审核

TAG: computing

我来说两句

OPEN

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