Cannonball

  1. Recall the cannonball simulation program which we developed in last semester.
  2. This time we are going to implement that in C language.
  3. However, instead of only printing out the total traveled distance and the maximum height after the simulation ends, this time you are required to print out the position of the cannonball at each time interval.
  4. The program may run as follows.
    
    Enter the launch angle (in degrees): 30
    Enter the initial velocity (in meters/sec): 20
    Enter the initial height (in meters): 0
    Enter the time interval between position calculations: 0.1
    
    Time    xpos    ypos
    0.1     1.7     1.0
    0.2     3.5     1.8
    0.3     5.2     2.6
    0.4     6.9     3.2
    0.5     8.7     3.8
    0.6     10.4    4.2
    0.7     12.1    4.6
    0.8     13.9    4.9
    0.9     15.6    5.0
    1.0     17.3    5.1
    1.1     19.1    5.1
    1.2     20.8    4.9
    1.3     22.5    4.7
    1.4     24.2    4.4
    1.5     26.0    4.0
    1.6     27.7    3.5
    1.7     29.4    2.8
    1.8     31.2    2.1
    1.9     32.9    1.3
    2.0     34.6    0.4
    2.1     36.4    0.0
    
    
  5. The flowchart may look like the following:
  6. If your output does not look like the example, you may consider improving it by
    1. std::setprecision
    2. std::fixed
    3. Conditional Operator