Spread the word.

Share the link on social media.

Share
  • Facebook
Have an account? Sign In Now

Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

SIKSHAPATH

SIKSHAPATH Navigation

  • Home
  • Questions
  • Blog
    • Computer Science(CSE)
    • NPTEL
    • Startup
  • Shop
    • Internshala Answers
Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Home
  • Questions
  • Blog
    • Computer Science(CSE)
    • NPTEL
    • Startup
  • Shop
    • Internshala Answers
Home/ Questions/Q 4829
Next

SIKSHAPATH Latest Questions

SUMIT
  • 0
  • 0
SUMIT
Asked: November 16, 20212021-11-16T21:36:38+05:30 2021-11-16T21:36:38+05:30In: Programming Language

Problem 24: Baseball Statistics The local Kids’ League coach keeps

  • 0
  • 0

Problem 24: Baseball Statistics
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:
Sam Slugger,h,h,o,s,w,w,h,w,o,o,o,h,s
Jill Jenks,o,o,s,h,h,o,o
Will Jones,o,o,w,h,o,o,o,o,w,o,o
The file BaseballStats.java contains the skeleton of a program thats reads and
processes a file in this format. Study the program and note that three Scanner
objects are declared.
• One scanner (scan) is used to read in a file name from standard input.
• The file name is then used to create a scanner (fileScan) to operate on that file.
• A third scanner (lineScan) will be used to parse each line in the file. Also note
that the main method throws an IOException. This is needed in case there is a
problem opening the file. Complete the program as follows:
1. First add a while loop that reads each line in the file and prints out each part
(name, then each at bat, without the commas) in a way similar to the
URLDissector program in Listing 5.11 of the text. In particular inside the loop you
need to a. read the next line from the file b. create a comma delimited scanner
(lineScan) to parse the line c. read and print the name of the player, and finally,
d. have a loop that prints each at bat code.
2. Compile and run the program to be sure it works.

java
  • 0 0 Answers
  • 98 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    Sidebar

    store ads

    Stats

    • Questions 1k
    • Answers 1k
    • Posts 149
    • Best Answers 89
    • This Free AI Tool Translates Entire Books in Minute !
    • AI News: 🎬 Hollywood’s AI Studios, 🎓 OpenAI’s Latest Gift to Educators, 🚚 Class8 Bags $22M, 🧠 Google Gemini’s Memory Upgrade
    • AI NEWS: Legal Action Against OpenAI, $16M Paid, & Elon Musk’s Praise from Investor 🤖💰📑 | AI Boosts Cloud Seeding for Water Security 🌱💧
    • AI News: 🎬AI Video Tool Scam Exposed🤯, 🛰️ AI-Powered Drones to Ukraine 😱, Google’s $20M AI Push, Sam Altman Joins SF’s Leadership Team
    • AI News: 🤝 Biden Meets Xi on AI Talks, 💡 Xavier Niel’s Advice for Europe, ♻️ Hong Kong’s Smart Bin Revolution, 🚀 AI x Huawei

    Explore

    • Recent Questions
    • Questions For You
    • Answers With Time
    • Most Visited
    • New Questions
    • Recent Questions With Time

    Footer

    SIKSHAPATH

    Helpful Links

    • Contact
    • Disclaimer
    • Privacy Policy Notice
    • TERMS OF USE
    • FAQs
    • Refund/Cancellation Policy
    • Delivery Policy for Sikshapath

    Follow Us

    © 2021-24 Sikshapath. All Rights Reserved

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.