Write a fragment of code that computes the final score of a baseball game. Use a loop to read the number of runs scored by both teams during each of nine innings. Display the final score afterwards.
What will be an ideal response?
```
int innings = 9;
int team1Total = 0;
int team2Total = 0;
//Scanner reader = new Scanner(System.in);
for( int inning=1; inning <= innings; inning++){
System.out.println("How many runs were scored in inning "
+ inning + " by each team?");
team1Total = team1Total + reader.nextInt();
team2Total = team2Total + reader.nextInt();
}
System.out.println("The first team scored: " + team1Total
+ " and the second team scored: " + team2Total);
```
This code is in Fragments.java.
You might also like to view...
When you are adding ActiveX controls to a worksheet, you are working in ________
Fill in the blank(s) with correct word
There are how many different types of cell references?
A) Four B) Five C) Three D) Two