这是我迄今为止。它告诉我,我在下面标出的行上有一个语法错误,表示它预期分别是“{”和“}”,而没有双引号。有什么建议么?试图做一个简单的落球程序
public class attempt1 {
//use Euler-Richardson algorithm
//defining the initial conditions
double v0=30;
double theta=40;
double x0=0;
double y0=0;
double v0x=v0*Math.cos(Math.toRadians(theta));
double v0y=v0*Math.sin(Math.toRadians(theta));
double dt= .01;
double ax=0;
double ay=-9.8;
double x=0;
double y=0; //this line here, on the semi-colon
while (y>=0) {
double vx= v0x+1/2*ax*dt;
double vy= v0y+1/2*ay*dt;
double x= x0+1/2*vx*dt;
double y= y0+1/2*vy*dt;
if (y<=0){System.out.println(x);}
}
} //and right over here, on the brace itself
你不能把任何陈述的方法(或构造函数或初始化程序)之外。 – immibis 2015-02-10 22:46:55
对不起,我在编码方面很新颖(大约2周,哈哈)。你到底在哪里? – helpmepls 2015-02-10 22:50:42
你需要把while循环放在一个方法中 - 可能看起来像'public static void main(String [] args){/ * while loop here * /}' – 2015-02-10 22:56:10