Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions