Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the assignment that I have been working on. I am running into an error and I do not know how to fix. Please

This is the assignment that I have been working on. I am running into an error and I do not know how to fix. Please help me resolve it. Below is the code and the screenshots of Error, Design & Assignment.

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO;

namespace SinghAjayProgram07 { public partial class worldSeriesChampions : Form { public worldSeriesChampions() { InitializeComponent(); }

List champList = new List();

int i = 0;

private void worldSeriesChampions_Load(object sender, EventArgs e) { StreamReader teamsFile = File.OpenText("Teams.txt");

StreamReader winnersFile = File.OpenText("WorldSeriesWinners.txt");

string reader;

while ((reader = teamsFile.ReadLine()) != null) { teamsListBox.Items.Add(reader); }

while ((champList[i] = winnersFile.ReadLine()) != null) { i++; } }

private void teamsListBox_SelectedIndexChanged(object sender, EventArgs e) { string reader = teamsListBox.SelectedItem.ToString();

int j = 0; int count = 0;

while (j

j++; }

resultTextBox.Text = (reader + "Won" + count + "times."); } } }

Error Screenshot:

image text in transcribed

Design screenshot:

image text in transcribed

The Assignment:

image text in transcribed

26 27 Diagnostics session: 0 seconds streanReader teamsFile- File.OpenText ("Teans.txt.); StreaReader winnersFile File.OpenText "HorldSerieswinners.txt") string reader; while Events 29 Process Memory 32 100 1 ((reader teams File-Read Line()) != null) : toamsListBax.Itons.Add (readar); 36 37 CPU 1% of all processors) 100 uhile ((champlist[i]- winnersFilo.Readline())) 48 Exception Unhandled ndex was out of range. Summary Events Memory Usage CPU Usage Must be non-negative and less than the size of the collection. Farameter name index private void teansListBox SelectedIndexChanged (object sender Show Events (1 of 1 46 string reader teansListBox.SelectedItem. ToString); Memory Usage View Delails Copy Details B Take Snapshot Fxception Settings int count ; CPU Usage 50 Recrd CPU Profile Locals Call Stack alue 'Index was cut ef range. Must be non-negative and less than the External Codel this sender (SinghAjaProgramoworldSerieschampions, Text: World Series Systerm.EventArgs (System,l0 StreamRcader) System.loStreamReader objecinghAjayr System EventArgs LExternal Codel SirnghAjayProa7.exlSinghAjayPrPrera.MnLie 19 tcamsFile winnersFile e reader Locals Watch 1 Call Stack Exception Settings Immediate Window O Ready Ln 38 Col 13 Ch 13 t Add to Scurce Control World Series Champions List of World Series Champions Click on any team to find out how many times it has won World Series Championship teamsListBox Exit World Series Champions In the Chap07 folder of the Student Sample Programs, you will find the following files: Teams.txt This file contains a list of several Major League baseball teams in alphabetical order. Each team listed in the file has won the World Series at least once. WorldSeriesWinners.txt-This file contains a chronological list of the World Series' winning teams from 1903 through 2012. (The first line in the file is the name of the team that won in 1903, and the last line is the name of the team that won in 2012. Note that the World Series was not played in 1904 or 1994.) Create an application that displays the contents of the Teams.txt file in a ListBox control. When the user selects a team in the ListBox, the application should display the number of times that team has won the World Series in the time period from 1903 through 2012

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions

Question

Write an elaborate note on marketing environment.

Answered: 1 week ago

Question

5. How do instructional objectives help learning to occur?

Answered: 1 week ago

Question

4. Help trainees set challenging mastery or learning goals.

Answered: 1 week ago