A mean with rejected readings

Mark Yourself Question

  1. Grab a piece of paper and try this problem yourself.
  2. When you're done, check the "I have answered this question" box below.
  3. View the solution and report whether you got it right or wrong.

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:

  • Accept readings from zero through limitN, including both endpoints.
  • Return the arithmetic mean of accepted readings in newtons.
  • Return -1.0 as a status value if there are no accepted readings.
  • Use a For...Next loop and leave the array unchanged.

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.


Visual Basic
MeanAcceptedForce(New Double() {-2.0, 0.0, 8.0, 12.0, 30.0}, 20.0)
MeanAcceptedForce(New Double() {-4.0, 24.0}, 20.0)

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Visual Basic Questions: