Question: For this project you will complete Chapter 8 , Project 6 , Baseball as described on page 4 5 1 . The program will allow

For this project you will complete Chapter 8, Project 6, Baseball as described on page 451. The program will allow the user to select a major league baseball team from a list box and then display the players from that team whose batting average was above the average of his teammates batting averages. The data is stored in an XML document named BaseballBattingAverages.xml that is provided in a compressed (zipped) folder in Blackboard. The form design is shown on page 451 in Figure 8.45. The program requirements and calculations are also described on page 451. Choose meaningful names for the form controls and the event procedure variables.
1. Declare a class-level variable using XElement to store the
BaseballBattingAverages.xml file data.
2. Create a form Load procedure. The goal for the procedure is to identify each unique baseball team name and list them in alphabetical order in the list box. Create a query that processes each player parent element and uses the team values to sort the records by team, select team, and only keep each distinct team. Each item that is selected in the query will then be looped through using a For Each statement to output each team name in the list box.
3. Create a list box SelectedIndexChanged procedure that includes the following code:
3A. The first query is used to identify the selected teams overall batting average. Create a query that processes each player parent element, uses Let statements to store the team, atBats, hits, and calculated batting average (hits/atBats). Select the records where team matches the team that was selected in the list box, and then select batting average.
3B. Save the batting average in a teamAverage variable using query.Average.
3C. Create a second query that is used to select the players on the selected
team that have a higher batting average than the team average. The query will process each player parent element. Let statements will save name, team,
atBats, hits, calculated batting average for this player, and a formatted batting
average that uses three decimal points in the number. Use Where to identify that a player is on the selected team and has a higher batting average than the teamAverage calculated in 3B. Order By battingAverage in descending
order and select the resulting name and formatted batting average.
3D. Display the query results in a data grid, mark the current cell as Nothing, and change the two column headers to be Player and Batting Average.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!