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.

Computer Science & Information Technology

You might also like to view...

StringBuilder greeting = new StringBuilder("Hello, John"); char initial = greeting.charAt(7); ? Using the above code and the charAt() method, what value will be assigned to the variable initial?

What will be an ideal response?

Computer Science & Information Technology

Match each statement with the appropriate term.

A. describes a file with any characters removed that are not needed by a browser to parse the file B. describes an image file that is as compressed as possible without losing significant visual information C. a style rule based on selectors that no longer apply to any elements on your web pages D. a version of a library that includes only the features that your site uses E. a single image file that includes multiple smaller images arranged side-by-side or in a grid

Computer Science & Information Technology

If you are only creating a report, it is not necessary to check the record set of the query

Indicate whether the statement is true or false

Computer Science & Information Technology

What Windows utility is particularly useful in identifying software and hardware bottlenecks, and provides the ability to monitor in real time?

A. Event Viewer B. Reliability Monitor C. Performance Monitor D. Resource Monitor

Computer Science & Information Technology