Assignment 1: C++
For a perfectly elastic bouncy ball dropped from a height of \(h\) will bounce on the floor, the time between bounces (the "bounce time") would be given by
\[ t = \sqrt{\frac{8h}{g}} \]
where \(g\) is the gravitational acceleration on earth.
Now consider a set of \(n\) bouncy balls dropped from successively higher points, such that the \(i\) -th ball is dropped from a height
\[ h_{i} = h_{avg} \frac{i}{2n} \]
where \(h_{avg}\) is the average drop point of the set, and \(i\) should run from 0 to \(n-1\) (true to the C++ style to start counting at zero).
Note: there is a typo in the above formula, the 2 should be in the numerator for \(h_{avg}\) to be the average, but since it's already posted we'll leave the formula as is so everyone's assignment computes the same thing.
Your assignment is to write a C++ program that can compute and output the bounce times of this set of bouncy balls.
Your program:
- should take the input parameters \(n\) and \(h_{avg}\) from keyboard (you can use the value 9.81 m/s2 for the gravitational accelleration \(g\));
- should write out (to screen or to a file, your choice) a set of lines with each line containing the drop-height (in meters), a space, and then the bounce time (in seconds);
- should be a single file;
- should have explanatory comments;
- should contain, apart from the main function, at least 2 other functions
- should not use global variables.
You should submit two files to the course website by midnight (ET) January 19th, 2023:
- the file with your code
- a file containg the output for the case \(h_{avg}=100\), \(n=100\).
Both files should be plain text files (so no .doc, .docx, .rtf, .pdf, .odt, .ods, ... files)