CE En 270 - Homework #11

Roadkill Analysis

Design  and write a "Roadkill" spreadsheet using VB code.  Your can organize/layout the spreadsheet any way you wish, but your spreadsheet may look something like this:

In this scenario, the user is driving down a road and specifies the  constant speed at which he is traveling. As the user drives along, he spots a opossum crossing the road in front of him.  The opossum freezes in its tracks and the user slams on his brakes. The spreadsheet should let the user know if he was able to stop in time.

It takes the average driver about 0.7 seconds to apply the brakes after seeing the need to stop; this is called the driver's reaction time. Once the brakes are applied, the car decelerates. Assuming a constant deceleration a, the braking distance x is given by:

            x = v2/(2a)

The deceleration is given by:

            a = ug

Where g is the acceleration due to gravity (9.8 m/s2) and u is the coefficient of friction between the car's tires and the road.

The spreadsheet should allow the user to specify his speed (km/hr), the distance (m) at which he spots the opossum, the road conditions (for wet road, u = 0.1, for dry road u = 0.6), and his own reaction time (fast = 0.4 seconds, average = 0.7 seconds, slow = 1.1 seconds). (Make sure you are consistent with your units!).

Your spreadsheet should include two option groups as shown above.  Be sure to use a unique group name for each set of option controls.  When the user clicks on one of the option controls, you should update the value in the appropriate cell (reaction time or friction coefficient).  When the user clicks on the Compute button, you should copy the values of the four input cells to double variables, perform the calculations, and put the result in the Stopping Distance cell.  You may also wish to give a text description of the result as shown above.

For this assignment, you may wish to use the VB If statement.  The syntax of the if statement is as follows:

If (condition) Then

    <code that is executed if the condition is true>

Else

    <code that is executed if the condition is false>

End If

For example

If stopdistance < distance1 Then
    Range("result") = "The possum is safe."
Else
    Range("result") = "The possum is dead!"
End If

We will learn more about the If statement later in the semester.

Submittal Instructions:

Click here to upload your homework assignment.