Use a 2D array to create a baseball scoreboard - 2 teams, 9 innings. We will update the scoreboard at the end of each half-inning. Use console I/O, and following is a sample run of the program:

How many runs did the visiting team score in inning #1: 0
How many runs did the home team score in inning #1: 0

How many runs did the visiting team score in inning #2: 0
How many runs did the home team score in inning #2: 0

How many runs did the visiting team score in inning #3: 1
How many runs did the home team score in inning #3: 0

How many runs did the visiting team score in inning #4: 0
How many runs did the home team score in inning #4: 2

How many runs did the visiting team score in inning #5: 0
How many runs did the home team score in inning #5: 0

How many runs did the visiting team score in inning #6: 0
How many runs did the home team score in inning #6: 1

How many runs did the visiting team score in inning #7: 2
How many runs did the home team score in inning #7: 0

How many runs did the visiting team score in inning #8: 0
How many runs did the home team score in inning #8: 2

How many runs did the visiting team score in inning #9: 0
How many runs did the home team score in inning #9: 0
Game's over, here's our scoreboard:
Inning: 1 2 3 4 5 6 7 8 9
Visitors: 0 0 1 0 0 0 2 0 0 3
Home: 0 0 0 2 0 1 0 2 0 5

Home Team Wins!!!

As you probably know, if the home team is ahead at the end of 8½ innings then they have won the game and they don't come up to bat in the bottom half of the 9th inning. Modify your program so that it does not ask how many runs the home team got in the 9th inning if they have already won the game, and the scoreboard should now display a dash rather than a zero for the home team in the 9th inning. If you do this bonus then just turn in the bonus code, do not also include the "regular" code.

What about extra innings? Rewrite your program to use an ArrayList rather than an array. Create it with an initial capacity of 9 innings. It should stop asking for additional input when one of the teams has won. If you do this bonus then submit it as a second program.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.