Project 5: Calculating the average of the numbers in... TextBox Objects

advertisement
Project 5: Calculating the average of the numbers in an array of
TextBox Objects
To do this project, use the starter application. The starter application is posted as a zip file.
Create a directory for the application on your computer and expand the zip file to that directory.
Open the project in that directory to start working on it.
Operation

Operation of the program is similar to the Array of TextBoxes in class exercise. However --Instead of adding the items in the TextBoxes, this program calculates the average of the nonzero items in the TextBoxes.

Initially the following screen should displayed:

When the Clear button is pressed, an Average button appears and each of the TextBoxes is set
to “0”. You can use btnname.Show(); to make the Average button appear.

When the Average button is pressed, the average of the non-zero items is calculated and
placed in the Average TextBox.
Specifications

Use a loop to convert the data in the TextBoxes to decimal and add the data to the sum.

In the loop, you will also need to keep track of the count of non-zero data items in the
TextBoxes.

Be sure to test for non-numeric data in the TextBoxes and popup a message if nonnumeric data is entered.

After the loop, divide the accumulated sum by the count of non-zero data items to
calculate the average.

Be sure you don’t divide by 0, since that will terminate the program. If all data items are
0, place a zero in the Average TextBox.

You do not need to document the code in this project.
Submitting the project
Follow the instructions in the syllabus for submitting projects. Be sure you submit the
project correctly.
Grading
Clear button places “0” in each TextBox
Loop operates correctly
Sum calculated correctly
Average calculated correctly
(Non-zero data items only)
Check for non-numeric data in the TextBoxes
Proper handling of a zero denominator
in the division
15%
15%
15%
Total
100
25%
10%
20%
Download