The local Kids’ League coach keeps some of the baseball team statistics in a text file organized as follows: each line of the file contains the name of the player followed by a list of symbols indicating what happened on each at bat for the player. The letter h indicates a hit, o an out, w a walk, and s a sacrifice fly. Each item on the line is separated by a comma. There are no blank spaces except in the player name. So, for example the file could look as follows: Willy Wonk,o,o,h,o,o,o,o,h,w,o,o,o,o,s,h,o,h Sam Slugger,h,h,o,s,w,w,h,w,o,o,o,h,s In this problem you will a create a program that reads raw data from a text file and prints properly formatted statistics. For instance, a sample output for the first player in the example: Statistics for Willy Wonk:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a Java Program

The local Kids’ League coach keeps some of the baseball team statistics in a text file
organized as follows: each line of the file contains the name of the player followed
by a list of symbols indicating what happened on each at bat for the player. The
letter h indicates a hit, o an out, w a walk, and s a sacrifice fly. Each item on the
line is separated by a comma. There are no blank spaces except in the player name.
So, for example the file could look as follows:
Willy Wonk,o,o,h,o,o,o,o,h,w,o,o,o,o,s,h,o,h
Sam Slugger,h,h,o,s,w,w,h,w,o,o,o,h,s
In this problem you will a create a program that reads raw data from a text file and
prints properly formatted statistics. For instance, a sample output for the first
player in the example:
Statistics for Willy Wonk:
Hits: 4
Outs: 11
Walks: 1
Sacrifices: 1
Batting Average: 0.267.
1. Create a text file “stats.txt” containing the data below:
Willy Wonk,o,o,h,o,o,o,o,h,w,o,o,o,o,s,h,o,h
Shari Jones,h,o,o,s,s,h,o,o,o,h,o,o,o,o
Barry Bands,h,h,w,o,o,o,w,h,o,o,h,h,o,o,w,w,w,h,o,o
3
Sally Slugger,o,h,h,o,o,h,h,w
Missy Lots,o,o,s,o,o,w,o,o,o
Joe Jones,o,h,o,o,o,o,h,h,o,o,o,o,w,o,o,o,h,o,h,h
Larry Loop,w,s,o,o,o,h,o,o,h,s,o,o,o,h,h
Sarah Swift,o,o,o,o,h,h,w,o,o,o
2. In your program, scan through the lines of the file and print each line as is on a
separate Line 3.
In addition to simply printing each line, you will parse each line of the file and
count the number of hits, outs, walks and sacrifices as well as the batting average
(3 digits after the decimal point) which is the number of hits divided by the total
number of hits and outs (Make sure to avoid dividing by zero).
Refer to sample output above
Hint: You will need to create another Scanner that takes as parameter the line
you want to go through. Make sure to use the correct delimiter.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY