Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help with this JAVA program, can't use arrays, can use if and while loops. Build a program to prompt the user for the names
Need help with this JAVA program, can't use arrays, can use if and while loops.
Build a program to prompt the user for the names of files that contain the outcomes of games from a given season in a given sport. The program then determines the number of games played with a home team, the number and percentage of those games the home team won, and the average point difference between the home team and the away team in those games.
The data files have the following form:
Your program must:
- display an intro (this is already done)
- prompt the user for the name of a file with game data; keep prompting the user until they enter the name of a file that actually exists
- print out the header for the file (see the examples)
- process the file and print out:
- the total number of games
- the number of games with a home team
- the percentage of games with a home team
- the number of games with a home team that the home team won
- the percentage of games with a home team that the home team won (had a higher score than the away team)
- the average difference between the score of the home team and the away team This is simply: Note, there are several ways to calculate this value.
- After processing the data file ask the user if they want to process another file or not and continue as appropriate
//An example of file NCAA Women's Basketball 2011 - 2012 2007-11-11 Rice 63 @Winthrop 54 O1 2007-11-11 @S Dakota St 93 UC Riverside 90 O2 2007-11-11 @Texas 92 Missouri St 55 2007-11-11 Tennessee 76 Chattanooga 56 2007-11-11 Mississippi St 76 Centenary 57 2007-11-11 ETSU 75 Delaware St 72 O1 Preseason NIT 2007-11-11 @South Alabama 72 Sam Houston St 54 2007-11-11 Auburn 91 Detroit 47 2007-11-11 @Missouri KC 65 Air Force 59 2007-11-11 Ga Southern 67 @Stetson 51 2007-11-11 @UT San Antonio 77 Belmont 65 2007-11-11 Hampton 71 @St Louis 57 O1 2007-11-11 @Vanderbilt 68 Furman 51 2007-11-16 IUPUI 60 Marshall 49 Preseason NIT /* Each line with a game result has the following format: The flags indicate information such as an overtime game and / or playoff game. The optional information may indicate the tournament or series the game was a part of, or the venue for neutral sites. The home team for the game, if any is indicated by the @ symbol at the start of the team name. Either team 1 or team 2 could have been the home team. So for example in the following game Texas (team 1) was the home team: 2007-11-11 @Texas 92 Missouri St 55 and in the following game Winthrop was the home team: 2007-11-11 Rice 63 @Winthrop 54 O1 The following game had no home team and was played on a neutral site: 2007-11-11 Mississippi St 76 Centenary 57 */
example output A program to analyze home field advantage in sports. Enter the file name: WBB8.txt Sorry, that file does not exist Enter the file name: wbb08s Sorry, that file does not exist Enter the file name: Sorry, that file does not exist Enter the file name: wbb08s.txt ********** NCAA Women's Basketball --- 2011 - 2012 ********** HOME FIELD ADVANTAGE RESULTS Total number of games: 14 Number of games with a home team: 9 Percentage of games with a home team: 64.3% Number of games the home team won: 6 Home team win percentage: 66.7% Home team average margin: 6.00 Do you want to check another data set? Enter Y or y to analyze another file, anything else to quit: y Enter the file name: wbb14.txt ********** NCAA Women's Basketball --- 2013 - 2014 ********** HOME FIELD ADVANTAGE RESULTS Total number of games: 15,790 Number of games with a home team: 14,305 Percentage of games with a home team: 90.6% Number of games the home team won: 8,471 Home team win percentage: 59.2% Home team average margin: 4.24 Do you want to check another data set? Enter Y or y to analyze another file, anything else to quit: y Enter the file name: wscc10.txt ********** NCAA Women's Soccer --- 2010 ********** HOME FIELD ADVANTAGE RESULTS Total number of games: 10,593 Number of games with a home team: 9,941 Percentage of games with a home team: 93.8% Number of games the home team won: 5,392 Home team win percentage: 54.2% Home team average margin: 0.51 Do you want to check another data set? Enter Y or y to analyze another file, anything else to quit: n
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started