来该实验(期间上课时间满着),实验有很多挫折,翻了书本和 PPT,也查阅
了相关资料,比如输入语句前要 import java.util.*;Scanner sc = new
Scanner(System.in);这是 c 与 c++,c#不同的,这些让我更加感受到 Java 的异
形和共性,虽然都是秉承着面向对象的思想,但是 Java 实现起来要更加简洁,
总的来说在通过此实验后,我学会了怎么使用 eclipse 实现基本输入输出,函
数调用等,总的来说还是学会了很多。
4、 程序关键代码
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
* System.out.println("HelloWorld!"); System.out.println("Lily 说:\"早
上好!\"");
* System.out.println("\"ab\"=\'a\'+\'b\'");
* System.out.println("绝对路径:D:\\QIBINGWANG.jpg"); int
temp1=30,temp2=25;
* System.out.println(temp1<=temp2);
*/
Scanner sc = new Scanner(System.in);
double speed = sc.nextDouble();
double degrees = sc.nextDouble();
int N = sc.nextInt();// 输出行数
double radians = Math.toRadians(degrees);
// double toRadians(弧度)(double d);数字转化为角度
double x;
double y;
double t = speed * Math.asin(radians) / 5.0;
int n = 0;// 从第一行开始
int i;
System.out.printf("speed=%.2f(m/s),degrees=%.2f(C)\n", speed,
degrees);
System.out.printf("sin=%.2f,cos=%.2f\n", Math.sin(radians),
Math.cos(radians));
for (i = 0; i < t / 1; i++, n = n + 1) {
x = speed * Math.cos(radians) * t;// x=vcos(degree)t
y = speed * Math.sin(radians) * t - 1 / 2.0 * 10 * t * t;//
y=vsin(degree)t-1/2gtt
System.out.printf("N=%d X=%.2f Y=%.2f T=%.1f\n", n, x, y, t);
}
System.out.printf("N total=%d\n", n);
}