Mark Yourself Question
Write a Visual Basic .NET function named MeanAcceptedForce with two parameters: a Double array named readingsN, containing forces in newtons, and a Double named limitN, also in newtons.
The function must:
Assume the array exists, all readings are finite, and limitN is finite and nonnegative. The array may be empty. Place the function inside a module, outside Sub Main, and use explicit parameter and return types.
Show the returned value for each call below. Report a valid mean to two decimal places.
MeanAcceptedForce(New Double() {-2.0, 0.0, 8.0, 12.0, 30.0}, 20.0) MeanAcceptedForce(New Double() {-4.0, 24.0}, 20.0)
Unlock full course notes by signing up
A mean from alternate readings
A Visual Basic .NET program selects every second reading from a force sensor, beginning with the first array element. The following statements execute inside Sub Main:
What value is stored in meanN? Give your answer in newtons, to two decimal places.
Tracing overlapping mode ranges
A test program converts a sensor voltage into a force using a mode-dependent gain. Its Visual Basic function contains a selection block, which chooses a branch using the value of mode. The function is declared inside a module.
For each independent test below, the program obtains the gain from GainFor(mode) and calculates force from:
Repairing an averaging routine
A Visual Basic .NET program is intended to calculate the arithmetic mean of all four force readings in newtons. Its calculation currently contains two logic errors:
Which change fixes both errors while retaining the existing loop bounds?
Following copied and referenced command values
A test controller uses the following Visual Basic program to update a force command. All numeric command and increment values represent newtons. In the first call, the same caller variable appears in both argument positions.
Find the values stored in afterFirst and afterSecond when Main finishes. Give each answer in N, to one decimal place.