Problem Solving and Computer Programming

To become more familiar with:

- C program creation, compilation, and execution
- Sequence, Selection, and Repetition Control Structures
`while`,`for`, and`do while`instructions in C

- (35 points)
To help Issac Newton with his gravity experiments, you must write a
program called
`campusid_grav.c`for calculating the position of a falling object at given time intervals. The program should take as input from Sir Issac the initial height from which the object is dropped, and the change in time for printing the position.

The physics of the system are simple. Let h_{0}be the initial height of the object, let Δt be the size of the time intervals for calculating the new height, and let g be a constant acceleration due to gravity. Then,

h _{1}= h(Δt) = h_{0}- g(Δt)^{2}

h_{2}= h(2Δt) = h_{0}- g(2Δt)^{2}

h_{3}= h(3Δt) = h_{0}- g(3Δt)^{2}

.

.

.

h_{t+1}= h((t+1)Δt) = h_{0}- g((t+1)Δt)^{2}

The program should prompt the user for a**positive**starting height and a**positive**change in time (i.e. Δt). The constant of acceleration should be

#define G 9.8

The program should output the starting time (0.0), the starting height, and then all subsequent times (Δt, 2Δt, 3Δt, ...) and the heights at each time. The program should terminate once the height reaches 0 or passes below 0, printing the ending position of 0.0. You do not need to worry about units. As an example, the following is the output for h_{0}= 10 and Δt = 0.2.

0.0 10.00 0.2 9.60 0.4 8.43 0.6 6.47 0.8 3.72 1.0 0.20 1.2 0.00

- (40 points)
Create a program called
`campusid_arith.c`to calculate arithmetic tables for the operations +, -, *, and /. Using a menu, have the user select the operator of choice. Once the operator is selected, the user should be prompted for an operand range in [1,100]. The user will need to input both a minimum value (min) for the range and a maximum value (max) for the range. Error checking should be used to ensure that min is less than max and that min and max are between 1 and 100 inclusive. Once the user input is collected, the program should calculate the arithmetic table for the selected operator in the range of integer values and print the results in a nicely formatted table.

As an example, for the operand + and an input range of [3,7], the nicely formatted output table would be

+ 3 4 5 6 7 3 6 7 8 9 10 4 7 8 9 10 11 5 8 9 10 11 12 6 9 10 11 12 13 7 10 11 12 13 14

While it is possible to accomplish this various ways, you**MUST**employ a`switch`instruction for using the various operators. Be sure to test your program for all operators and various ranges of values. Note: the / operator requires the output to be floating-point -- in this case, display the result to two decimal places.

- (10 points
**EXTRA CREDIT**) Create a copy of your`campusid_arith.c`called`campusid_arith_enhanced.c`and modify it such that the user can enter a maximum value less than the given minimum value to display an arithmetic table with values in descending order instead of ascending order. The user should still be able to enter a maximum value greater than a minimum value and get the same result displayed by the original`campusid_arith.c`; in other words, your`campusid_arith_enhanced.c`should function exactly like`campusid_arith.c`with the additional capability of displaying values in descending order.

As an example, for the operand + and an input range of [7,3], the nicely formatted output table would be

+ 7 6 5 4 3 7 14 13 12 11 10 6 13 12 11 10 9 5 12 11 10 9 8 4 11 10 9 8 7 3 10 9 8 7 6

When you have finished, submit your

(optional)

Additionally, email your