Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

World Series Champions(visual basic program) In the Chapter 9 folder of the stud

ID: 3571822 • Letter: W

Question

World Series Champions(visual basic program) In the Chapter 9 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. Hint: Read the contents of the WorldSeriesWinners.txt file into a List or an array. When the user selects a team, an algorithm should step through the list or array count- ing the number of times the selected team appears.

WorldSeriesWinners.txt

Boston Americans New York Giants Chicago White Sox Chicago Cubs Chicago Cubs Pittsburgh Pirates Philadelphia Athletics Philadelphia Athletics Boston Red Sox Philadelphia Athletics Boston Braves Boston Red Sox Boston Red Sox Chicago White Sox Boston Red Sox Cincinnati Reds Cleveland Indians New York Giants New York Giants New York Yankees Washington Senators Pittsburgh Pirates St. Louis Cardinals New York Yankees New York Yankees Philadelphia Athletics Philadelphia Athletics St. Louis Cardinals New York Yankees New York Giants St. Louis Cardinals Detroit Tigers New York Yankees New York Yankees New York Yankees New York Yankees Cincinnati Reds New York Yankees St. Louis Cardinals New York Yankees St. Louis Cardinals Detroit Tigers St. Louis Cardinals New York Yankees Cleveland Indians New York Yankees New York Yankees New York Yankees New York Yankees New York Yankees New York Giants Brooklyn Dodgers New York Yankees Milwaukee Braves New York Yankees Los Angeles Dodgers Pittsburgh Pirates New York Yankees New York Yankees Los Angeles Dodgers St. Louis Cardinals Los Angeles Dodgers Baltimore Orioles St. Louis Cardinals Detroit Tigers New York Mets Baltimore Orioles Pittsburgh Pirates Oakland Athletics Oakland Athletics Oakland Athletics Cincinnati Reds Cincinnati Reds New York Yankees New York Yankees Pittsburgh Pirates Philadelphia Phillies Los Angeles Dodgers St. Louis Cardinals Baltimore Orioles Detroit Tigers Kansas City Royals New York Mets Minnesota Twins Los Angeles Dodgers Oakland Athletics Cincinnati Reds Minnesota Twins Toronto Blue Jays Toronto Blue Jays Atlanta Braves New York Yankees Florida Marlins New York Yankees New York Yankees New York Yankees Arizona Diamondbacks Anaheim Angels Florida Marlins Boston Red Sox Chicago White Sox St. Louis Cardinals Boston Red Sox Philadelphia Phillies New York Yankees San Francisco Giants St. Louis Cardinals San Francisco Giants

Teams.txt

Anaheim Angels Arizona Diamondbacks Atlanta Braves Baltimore Orioles Boston Americans Boston Braves Boston Red Sox Brooklyn Dodgers Chicago Cubs Chicago White Sox Cincinnati Reds Cleveland Indians Detroit Tigers Florida Marlins Kansas City Royals Los Angeles Dodgers Milwaukee Braves Minnesota Twins New York Giants New York Mets New York Yankees Oakland Athletics Philadelphia Athletics Philadelphia Phillies Pittsburgh Pirates San Francisco Giants St. Louis Cardinals Toronto Blue Jays Washington Senators

Explanation / Answer

import java.io.BufferedReader; import java.io.FileReader; public class CountWords { public static void main (String args[]) throws Exception { System.out.println ("Counting Words"); FileReader fr = new FileReader ("c:\Customer1.txt"); BufferedReader br = new BufferedReader (fr); String line = br.readLin (); int count = 0; while (line != null) { String []parts = line.split(" "); for( String w : parts) { count++; } line = br.readLine(); } System.out.println(count); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote