How to code this program?

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.
1) Grab a text editor
2) Write code
3) Compile
iHutch105, you are my new hero xD
I wouldnt tell it if i know how to code it
We are going to modify your barometer program from lab 2.

That seems to imply most of this is already done, it's just few modifications to what you already have finished?
Not so fast Chervil! See Lab 1 here: http://cplusplus.com/forum/beginner/91901/
OK I get the picture now. But it would seem there's no need to start work on this until the earlier part is done. Otherwise it might be duplicated effort.
Last edited on
Topic archived. No new replies allowed.