throw ball angle of 30 degrees at force of 80. Tell position of ball for next 10 seconds. - Java Algorithm

Java examples for Algorithm:Physics

Description

throw ball angle of 30 degrees at force of 80. Tell position of ball for next 10 seconds.

Demo Code


public class Baseball {

  public static void main(String args[]) {
    double angle = 30;
    double force = 80;
    int time = 0;

    for (time = 0; time <= 10; time++) {
      double x = Math.cos(Math.toRadians(angle)) * force * time;
      double y = Math.sin(Math.toRadians(angle)) * force * time + -9.8 * .5 * time * time;
      System.out.println(time + "\t(" + x + "," + y + ")");
    }//from   w  w  w. j  a  v  a  2s  . c  o  m
  }
}

Related Tutorials