如何在 for 循环中捕获计数器的特定值,为此我得到最大计算值..例如:
import com.imonPhysics.projectile2;
public class motion2{
public static void main(String[] args){
double range=0,v=35,maxrange=0,angle=0;
int x=0;
projectile2 p1=new projectile2();
System.out.println("the given velocity is: 20 m/s \n" );
System.out.println("The value of g is: 9.8 m/s^2\n\n" );
for(int j=0;j<=90;j+=5){
x=j;
range=p1.calculate(v,j);
System.out.println("For the angle :" + j+" the range is: " + range);
if(range > maxrange)maxrange=range;
}
System.out.println(" the maximum range is :"+ maxrange);
System.out.println(" the angle at which the range is max is : " + angle);
}
}
如何捕获最大范围的角度。