A.    Lab # CIS CIS170A-A1                 


B.    Lab 4 of 7: Loops (Iteration)                                  


C.    Lab Overview – Scenario / Summary:



5. Given a set of program specifications for a simple business problem requiring iteration, code and test a program that meets the specifications and employs best programming practices.

10. Given a program’s source code and its program specifications document, conduct a code walk-through to determine if the program meets the specification.


This lab will familiarize the student with For Next loops and Do While loops by calculating and displaying the total amounts of goals, assists, and points over a hockey player’s career.


IMPORTANT NOTE: This program will be used as the base for our Week 5 Lab.  In addition, the Week 5 Lab will be used as base for our Week 7 Lab. Needless to say, it is particularly important that you develop this Lab for Week 4 with care. Doubts?  Please ask!



D.    Deliverables:






Project Files



The Dropbox deliverables include the following.

1.     Include a zipped file with all the files from your Visual Basic project (see directions in Doc Sharing on how to collect and zip files.)

2.     Upload each part of the lab into its corresponding weekly Dropbox.


E.    Lab Steps:



If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.


Locate the Visual Studio 2010 icon on the desktop. Click to open.




Step 1: Create a New Project



Create a new Windows Forms project in VB.NET. Name your project CIS170A_Lab04.



Step 2: Program Description



In this project, you will create a program that will calculate and display the career statistics for a hockey player. The program will input the name of the hockey player (the name must be a non-empty string) and the number of seasons played, which must be at least one season and no more than 20 seasons. Processing the goals and assists cannot start until a valid “seasons” value is provided. Once the valid Seasons value is provided, the program will prompt the user to provide the number of goals and assists for each of those seasons. The valid number of goals is between 0 and 60 and the valid number of assists is between 0 and 60. The program will keep a running total of the number of goals, the number of assists, and the total points. Also, a list of each season’s data will be displayed after the season data is provided. Once all the season data are collected, the program shall list the summary information for the player and the totals for all seasons. See the suggested pseudocode below for processing details.


Consider using the following pseudocode as a guide in developing the main processing algorithm of the program:


1.     Accept and validate PLAYER NAME (from InputBox.)

2.     Accept and validate SEASONS (from InputBox.)

3.     Initialize display of data.

4.     Loop with Counter from 1 to Seasons:

a.     Accept and validate GOALS (from InputBox).

b.     Accept and validate ASSISTS (from InputBox).

c.     Display this season’s data (Goals and Assists).

d.     Accumulate Goals and Assists into TotalGoals and TotalAssists.

5.     Display TotalGoals, TotalAssists, and Points (TotalGoals + TotalAssists.)




Step 3: Suggested Form Design


You are free to experiment with form design and object colors as you see fit, even though as to colors we strongly recommend using the default colors for the form and all objects – this allows each user to see your form in their chosen Windows color palette.


The suggested form design is as follows:



The InputBox() function that is suggested for data input should display a dialog box similar to the following one:



Why the InputBox() function?  Well, the standard way to accept free-format input from the user in any GUI program is through textboxes, of course, as we have been doing in previous Labs.  In non-GUI programs, however, there are many such as in embedded systems, for example, and many other situations. For such programs, an specific “Accept Input” operation must be executed, and that is where the InputBox() function comes in.  By learning how to use the InputBox() function in this program, you will learn to handle such operations in non-GUI programs as well, even though we will do it within our Windows, GUI programs, of course.


Step 4: Implement the Event Handlers


Consider using the following suggested TOE chart as guide in designing your program’s event handlers:





  1. Accept and validate PLAYER NAME (from InputBox.)
  2. Accept and validate SEASONS (from InputBox.)
  3. Initialize display of data.
  4. Loop with Counter from 1 to Seasons:
    1. Accept and validate GOALS (from InputBox).
    2. Accept and validate ASSISTS (from InputBox).
    3. Display this season’s data (Goals and Assists).
    4. Accumulate Goals and Assists into TotalGoals and TotalAssists.
  5. Display TotalGoals, TotalAssists, and Points (TotalGoals + TotalAssists.)



Clear all textboxes and listbox



Close form




Programming notes:

1.  As shown in the reading, use a Do..Loop or For..Next statement to collect the season’s data, along with each season’s goals and assists information.

2.     When doing this loop obtaining the data for each season, use InputBox() functions to accept the data from the user.  (Please check p. 88 of our textbook for details on this function and please post question in class for clarification, if needed.)

3.     Please note that the InputBox() function is simple and it does NOT allow us to check to see if the user clicked on the Cancel button to exit the dialogue.  As such, there is no way to distinguish in our code between a user that enters nothing and clicks on “OK” and a user that may enter something but then clicks on “Cancel”.  In both cases, the returned string will be a null (empty) string: “”.

4.     Given the nefarious consequences of its use in programs, the GoTo statement CANNOT be used in this nor in any other program in our class. Instead of the GoTo statement, use Do..Loop statements.

5.  As shown in the reading, use a Listbox to list each season’s information.

6.  Do not allow using the button to get the statistics until the number of seasons has been validated.


Please remember to set Option Strict On / Explicit On / Infer Off and also to supply profuse internal documentation in your program.



Step 5: Executing the Program


To execute your code, click Start and then start debugging. Check your output to ensure that you have space(s) where appropriate. If you need to fix anything, close your execution window, modify your code as necessary, and rebuild.


Step 6: Deliverables



1.     Zip up the top-level folder with your program (the complete set of project files) into a single file (please check Doc Sharing for details.)

2.     Rename that .zip file as, or similar.

3.     Place deliverables in the Dropbox.

4.     Your Lab will be graded using the following rubric (I reserve the right to make minor corrections to it):








1. Hockey Statistics


Correct operation


Validation of user's input (w/loops)


Handling of data type conversions


Overall form design


Option Strict On / Explicit On / Infer Off set


Internal program documentation


Clean code.


2. Other issues
















  • 9 years ago
  • 20

Purchase the answer to view it

  • attachment
  • attachment