Tuesday, 20 August 2013

How can I trap a particular value of the counter in the for loop

How can I trap a particular value of the counter in the for loop

How can I trap a particular value of the counter in the for loop, for
which I get the maximum calculated value ..for example:
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);
}
}
how can I trap the angle for maxrange.

No comments:

Post a Comment