Question: ITN 261: Basketball Scorekeeper - Arrays Problem statement: You are tasked with writing a simple program will store and perform simple operations on a teams

ITN 261: Basketball Scorekeeper - Arrays

Problem statement:

You are tasked with writing a simple program will store and perform simple operations on a teams basketball scores over an 42 game season. For this assignment, you are given starter code that randomly generates the scores and stores them in a two dimensional array.

You have to create a menu that will allow the user to specify if they want to see average scores for the season by a selected quarter or to display the scores for a single game. After the program performs the operation, the menu should be redisplayed. The menu should also have a way to exit the program.

Finally, use Try..Catch statements to catch any errors that are caused by user input.

Starter code:

import java.util.Scanner; public class BasketballSeasonTracker { static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { // This 2 dimensional array holds scores for 42 games by quarter int[][] teamScores = new int[42][4]; // Initialize the array to random scores for (int game = 0; game < 42; game++) { for (int qtr = 0; qtr < 4; qtr++) { // We will assign a random number between 5 and 30 for each quarter) teamScores[game][qtr] = (int)(Math.random()*25) + 5; } } // View the scores for all games/quarters for (int game = 0; game < 42; game++) { System.out.println(" Game: " + (game+1)); for (int qtr = 0; qtr < 4; qtr++) { System.out.print("Q" + (qtr+1) + ": " + teamScores[game][qtr] + "\t"); } } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!