---- begin sample run ---- Drop your barometer. How long was it until you heard a crashing sound (in seconds)? 2.5 Your building is 30.65 meters tall. Now, you do realize that barometers are filled with mercury, right? Call the EPA NOW! ---- end sample run ---- Procedure --------- 1. Write out your pseudocode for how you are going to implement this program. Your pseuedocode should include a listing of the program's inputs, outputs, and the steps it performs. Also, during this part of the program, you'll want to identify the proper variable types for your inputs and outputs. 2. Set out a series of test cases (at least 5). Test cases should include a series of example inputs and the expected outputs. (see hints for how to do the math) 3. Using your favorite text editor, type out your pseudocode and test cases into a text file named "lab2-2-test". Submit this file using the turnin program: ~relowe/turnin lab2-2-test By the end of class on Wednesday 1/30/2013 4. Write your program in c++. Compile it, test it. Once it all works create a typescript file named "lab2-2-run" which contains the following: - A listing of your source code. (hint: use cat) - Running your compile command so I can see your code compiles without errors or warnings. - Sample runs of your program for each of your test cases. Be sure to type exit after you have generated all your output. Turnin your script file using: ~relowe/turnin lab2-2-test HINTS ----- - We want to make the program give output in meters. Therefore, our gravitational acceleration constant is g = 9.81 m/s^2. I would recommend creating a constant for g. - C does not have an exponent operator, therefore t^2 should be written as t*t. - The above example was computed as follows (in algebra, not C++): d = (1/2) * 9.81 * 2.5^2 = (1/2) * 9.81 * 6.25 = 30.65625 |
|
|
Part II: Improving the Barometer Drop (self lab) ================================================ The professor, angry at the loss of his favorite barometer, was less than patient when his wayward pupil returned. "You chowder head! That barometer has been in my family for over 4 generations!", he said. The boy replied "Sorry, but I was so excited, I also wrote this program to go with it." Never missing a chance to read good C++ code (I mean, who would pass it up?) he read over the work of his student. "Hmmm, this code is good. Not bad for a first attempt." the professor said. "What do you mean not bad?", the student replied. "Well, I would prefer if it could solve more aspects of the problem at hand. For instance, we live in the US, and thanks to the failings of Jimmy Carter, we still use the imperial system. It would be nice if it could work in either imperial and SI units. Also, it would be great if it could predict the number of seconds of a fall from a given height, as well as the final velocity of the fall." The student thought it over for a second and said "Well, it would be easy enough to store some choice variable about units. But what about the other parts?" The professor went to the board and wrote out several formulas in almost legible handwriting. He, of course, quickly erased them, but our intrepid student captured them! After all, he knows that you have to be quick on the draw to capture professorial notes! 1 2 d = --- gt 2 ________ | 2d | ---- t = \| g v = gt Also, he noted something about g being different in imperial units than it is in SI units. Unfortunately, the professor was too quick with the eraser for him to capture that one. Oh well, that's why google was invented! Procedure --------- We are going to modify your barometer program from lab 2. If you haven't finished it yet, please take this opportunity to get caught up. I will still give you credit for it, so long as you get it done by the end of this lab. This will be the last such extension, though future labs will include more time. 1. Modify the design of the program from last time to account for the change in requirements. Below is a sample run to illustrate how the changed program should behave: ---- begin sample run ---- Will you be working in: 1.) Metric 2.) Imperial Choice? What mode will you want? 1.) Height in terms of time. 2.) Time in terms of height Drop your barometer. How long was it until you heard a crashing sound (in seconds)? 2.5 Your building is 30.65 meters tall. The final velocity of the barometer was 24.5 m/s. Now, you do realize that barometers are filled with mercury, right? Call the EPA NOW! ---- end sample run ---- Note that the final velocity is always printed, and it should display the proper units. Submit your design by the specified due date. Be sure to include adequate test cases in both metric and imperial units for both modes of operation. 2. Modify your code to allow for these changes. 3. Generate a script file containing a listing of your source code (cat), your compile line (g++), and the runs of your program for all of your test cases. Submit it by the due date listed above. |
|
|
cin >> variable
|
|
|
|