Please turn in this assignment (and all future assignments for
this course) by emailing them to me .
Please use the subject of "Physics 222 HW4" for these assignments
(if you use the link above, the subject will be added automatically).
Please *attach * the source code to any programs that
you write for this assignment. If you write more than one program,
attach *each separately*. When answering the questions themselves
feel free to answer directly in the body of your message (or attach your
answers). I may take off points for assignments that are not
sent to me in the correct form.

#### Number Checker

Write a program that will use a separate function or subroutine to calculate all of the following quantities for a given integer:

- Whether the number is prime or not. For the purpose of this assignment consider numbers to be prime if their absolute value is prime.
- Whether the sum of the digits of the number is odd or even.
- What the square root of the number is.

Feel free to reuse your prime number code, but beware that you will have to take care of cases such as 0, 1, and negative numbers.

Show your results when using the following numbers as input: -127, 51, 0, -23459, 453, 77779, -1, and 7.

#### Rocket Motion

In this problem, you will solve write a C++ or Fortran progam to find the maximum height reached by a model rocket. Further background on the physics of model rockets is available from the Physics 332 Rocket Lab . In this problem use real/float variables that are at least 8 bytes (kind=8/double precision). The relevant force equation is :

F = m(t)a = -m(t)g -k v

where^{2}+T(t)*T(t)=b t(1-t)*is the time-dependant thrust for times from 0 to 1 second, with the thrust being 0 at all other times and*b=16 N/s*.^{2}*k*is the drag coeffient,*k= 1/2 C*, where_{w}ρ A*C*is a constant,_{w}=1.0*A=0.00100 m*is the area, and^{2}*ρ*is the density of air (1.2 kg/m^{3}). Since the loss of mass of the rocket engine is responsible for the thrust,*dm/dt*is proportional to*-T(t)*. The mass of the rocket before launch is 0.120 kg, while the mass after is 0.070 kg. So:m

_{i}= m_{i-1}- 6/b * (m_{o}- m_{f})*T_{i}*ΔtTo solve the rocket equation numerically, you will need to solve its difference equation equivalent:

v

After finding the speed, you will be able to find the height from:_{i}= v_{i-1}+ Δt (-g - k v_{i-1}^{2}/m_{i}+ T_{i}/m_{i})x

Of course to solve either of the above, you will already have to have forms for T_{i}= x_{i-1}+ Δt v_{i}_{i}and m_{i}.Think carefully about what condition must be met in order to find the maximum height.

The time step size

*Δt*can be crucial to getting accurate results. Find the maximum height with time steps of:- 0.1 s
- 0.001 s
- 0.00001 s
- 0.000001 s

Plot the height of the rocket as a function of time using the PGPlot library. Include a postscript (.ps) plot graph of the 0.00001 s time step case in your email for this assignment.

Do these results seem to be approaching any limiting value. Do you trust these results? Why or why not?