Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Java program that keeps up with the scores in a baseball games, then reports them. Ask the user for the home team
Write a Java program that keeps up with the scores in a baseball games, then reports them. Ask the user for the home team name and the visiting team name. Set up two arrays that will store the number of runs for nine innings, one for the home team and one for the visiting team. Set up a loop to ask the user for the number of runs scored by each team for each of the nine innings. Write a method (in the same program) that accepts the team name and the scores array (pg 422). The method will write a line that has the team name, the inning scores, and the total score for a team. Have the main method create headings, then call the method to print scores for each team. Example: Team Rangers Dodgers 1 0 Rubric: 2 1 0 3 0 0 4 0 1 5 2 0 0 0 7 2 0 8 0 1 . Doesn't total the number of runs for each team -10% 9 1 Hints/Tips: In the loop to get the runs scored for an inning, ask the use how many runs were scored for the home team (Rangers in the example). Then, ask about the visiting team (Dodgers in the example). Be sure to put the inning number in the request Example: How many runs did the Rangers score in inning 3? How many runs did the Dodgers score in inning 3? When you print, print the column headings in the main method, then call the print scores method twice, once for the home team and once for the visiting team. Be sure to send the team name. In the print scores method, create an accumulator to sum the number of runs scored and add it in the loop that prints the scores. You can use print or printf to print each score as long as you don't use the escape sequence. After all scores have been printed (the loop is complete), then you can print the total, but make sure to use or println so that it goes to the next line. It took me a little less than 35 minutes to complete 0 Doesn't use arrays to store the number of runs per inning -100% Doesn't ask the user for the home team and visiting team per inning -20% . Doesn't put the team name in the request for a given innings score -10% . Doesn't show the inning in the request for a given innings score -10% Doesn't ask for both the home and away score by inning -10% Doesn't use a method to print the scores -20% Total 6 2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import javautilScanner public class BaseballScores public static void mainString args Scanner scanne...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