Question: Please code this in C++. Lab 4C --- Using a Water Balloon to Strike Your Friend There is one day after you finish the C++

 Please code this in C++. Lab 4C --- Using a Water

Please code this in C++.

Lab 4C --- Using a Water Balloon to Strike Your Friend There is one day after you finish the C++ lab that you go to the top of Old Chemistry. You hold a water balloon and be ready to strike your friend who will pass by. You cannot wait. If it weren't for air resistance, you could just do a quick calculus calculation and figure out when to drop the balloon. However, we will have to approximate the deceleration due to air resistance to be a constant, Cait. We have to multiply Sait by the velocity of the balloon, as shown in the equation for Vn+1, given below. Assume you know how high you are above the top of your friend's head, and you know the walking speed and the walking distance of your friend. Based on the walking distance and walking speed of your friend, you can predict how many seconds (or minutes) your friend will reach the striking point. This time is called timel. Next, the most important thing next is to predict how long (called time2) it will take for the balloon to fall to the head of your friend. Let us divide time into 1 millisecond (ms) increments. This is small enough for us to do an approximation. Assume the balloon is falling at a constant speed during each individual interval. So, if you denotes the speed (in feet/second) n milliseconds after you drop the balloon, and da denotes the distance it has traveled in n milliseconds, we have do = 0 dn+1 = dn + /1000.0 Vo = 0 Vn+1 = Yn + 0.032Cair - Ya where Cair is some coefficient to represent the air resistance and it is reasonable to assume 0.0012 here. Reminder: do not use names v and d in your program; use longer and clearer ones. Now, if you know Cais, and how high (called ver Dist (vertical distance)) you are above the top of your friend's head, you can use just iterate the above calculation until dn+1 > verDist to find how long (i.e., time2) it takes the water balloon to fall. You can easily calculate how long (i.e., timel) it takes for your friend to reach the stricken point. In your program, the precision of timel and time2 should be accurate to two digits after the point. For example, you must represent 3.2678 second as 3.26 second (by truncating). It is considered a hitting case if the absolute value of timel-time2) is

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!