Create a Windows Form application program that will calculate and display the career statistics

profiledmpiney198x
wk4.docx

A. Lab # CIS 4

B. Lab 4 of 7: Loops (Iteration)

C. Lab Overview – Scenario / Summary:

TCOs:

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.

D. Deliverables:

Step

Deliverable

Points

5

Program Listing, Output, and Project Files

45

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. Create a single MS Word document and include the following:

· For each lab, copy and paste your code directly into the MS Word file

· Include screenshot(s) of your test data with test results. Enter enough data to demonstrate that all your code has been tested.

· Include another screenshot of the Visual Basic build output messages. Check your build output to make sure you have a successful build with (0) errors and (0) warnings. NOTE: The build output messages appear at the bottom of your window after you click the Build menu and before you click the Start Without Debugging option. Your build output messages provide a list of compiler warnings or errors and let you know whether your program compiled successfully.

· Include the Word document as part of the zipped project file.

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

E. Lab Steps:

Preparation:

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.

Lab:

Step 1: Create a New Project

Create a new 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 season value is provided. Once the valid season value is provided, the program will prompt the user to provide the number of goals and assists for each season. 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 the each season’s data will be display after the season data is provided. Once all the season data are collected, the program shall list the summary information for the player and all the seasons. See the flowchart below for processing details.

Hint 1: As shown in the reading, use a Do loop to collect the season’s data, along with each season’s goal and assist information.

Hint 2: As shown in the reading, use a list box to list each season’s information

Step 3: Build the Form

The following is the Object, Property, Setting, Event chart for the form controls, and each input field will have a label/input field pair. Also, group the related information in the associated group box.

The form and form controls will be logically placed on the form, the controls aligned and sized, and a logical tab order assigned to each of the form controls.

Object

Property

Setting

frmHockeyStats

Text

Hockey Player Statistics

lblHeading

Text

Name, Course Title, Week Number, Lab Title

grpPlayer

Text

Player Information

lblName

Text

Player Name:

txtName

Text

(empty)

lblSeasons

Text

Number of Seasons:

txtSeasons

Text

(empty)

grpStatistics

Text

Statistic Operations

btnGetStats

Text

Get Player Statistics

grpResults

Text

Season Results

lstSeasons

Items

(empty)

lblTotal

Text

(empty)

grpOperations

Text

Operations

btnClear

Text

Clear

btnExit

Text

Exit

You are free to experiment with colors and form design as you see fit. However, your application must meet the listed requirements.

Hint: to check if a textbox is the empty string, use the String.IsNullOrEmpty method, such as:

If Not String.IsNullOrEmpty(txtName.Text) Then

Hint: do not enable the button to get the statistics until the number of seasons has been validated, such as:

If seasons > 0 AndAlso seasons <= 20 Then

e.Cancel = False

btnGetStats.Enabled = True

Step 4: Implement the Event Handlers

Use the following as the design for your event handlers, referring to the flow chart for rules on input validation and processing. The final calculation SHOULD NOT be completed until all the input fields are validated.

Control Name

Event

Task

txtName

Validating

Get player name

Validate player name

txtSeasons

Validating

Get number of seasons

Validate number of seasons

Enable/disable get statistics command button

btnGetStats

Click

For each season

Get goals

Validate goals

Get assists

Validate assists

Calculate total goals

Calculate total assists

Calculate total points

Output season statistics in list

Next

Output season summary

btnClear

Click

Clear all textboxes and output label

btnExit

Click

Close program (hint: use “Me.close”)

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. Capture a screen print of your output (do a PRINT SCREEN and paste into an MS Word document).

2. Copy your code and paste it into the same MS Word document that contains the screen print of your output.

3. Save the Word document as CIS170A_Lab04_LastName_FirstInitial.

4. Zip up the Word document along with a complete set of project files into a single document.

5. Place deliverables in the Dropbox.

END OF LAB

Version 1.0 Page 1 of 9

4/9/2009 Lab Activity MDD WBG310-A1

Begin

Get: Name

Get: Seasons

0 < seasons <= 20?No

count <= seasons?

Get: Goals

Get: Assists

Yes

Points = Goals + Assists

TotalGoals = TotalGoals + Goals

TotalAssists = TotalAssists + Assists

TotalPoints = TotalPoints + Points

Count = Count + 1

End

Yes

count = 1

A

A

No

0 <= goals <=60?

Output:

“Goals must be between 0 and

60 –Try again”

No

Yes

0 <= assists <=60?

Output:

“Assists must be between 0 and

60 –Try again”

No

Yes

Output:

“Seasons must be

between 1 and 20 –

Try again”

Output

Season & Goals & Assists &

Points

Output:

Name & “ career statistics”

“Seasons & “ seasons &

“Goals: “ & TotalGoals &

“Assists: “ & TotalAssists &

“Points: “ & TotalPoints

Name empty?

No

Output:

“Name must be

provided”

Yes

Begin

Get: Name

Get: Seasons

0 < seasons <= 20?

Output: “Seasons must be between 1 and 20 – Try again”

0 <= goals <=60?

No

No

Output: “Goals must be between 0 and 60 – Try again”

count <= seasons?

Get: Goals

Get: Assists

Yes

No

Points = Goals + Assists TotalGoals = TotalGoals + Goals TotalAssists = TotalAssists + Assists TotalPoints = TotalPoints + Points

0 <= assists <=60?

Count = Count + 1

Yes

End

Output Season & Goals & Assists & Points

Output: Name & “ career statistics” “Seasons & “ seasons & “Goals: “ & TotalGoals & “Assists: “ & TotalAssists & “Points: “ & TotalPoints

Yes

count = 1

A

A

No

Output: “Assists must be between 0 and 60 – Try again”

No

Yes

Name empty?

Output: “Name must be provided”

Yes