Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In java please, Create a program called FootballScore that allows the user to re

ID: 3721214 • Letter: I

Question

In java please,

Create a program called FootballScore that allows the user to record the scores for each team for each quarter of a football game. The program should include a one-dimensional array that will hold the team names, and a two-dimensional array with two rows and four columns that will contain the number of points scored by each team in each of the 4 quarters. Use the arrays in parallel to match up team names with team scores, i.e., the first team in the team array will have its quarterly points in the first row of the points array. When the program is run, the user will input the team names and their scores for each quarter of the game. The program will then call a separate method called outputResults that accepts the two arrays as parameters and outputs the final game scores in appropriately aligned columns (see sample run below). Sample run: Enter the name of the 1st team: Ravens Enter the name of the 2nd team: Steelers Enter the 1st quarter points for the Ravens: 14 Enter the 1st quarter points for the Steelers: e Enter the 2nd quarter points for the Ravens: 21 Enter the 2nd quarter points for the Steelers: 0 Enter the 3rd quarter points for the Ravens: a Enter the 3rd quarter points for the Steelers: e Enter the 4th quarter points for the Ravens: 10 Enter the 4th quarter points for the Steelers: a Game Summary Ravens: 14 21 3 10 Steelers: 0 0 Ravens: 48 Steelers:

Explanation / Answer

Program



import java.util.Scanner;


public class FootbalScore
{

    public static void main(String[] args)
    {
       Scanner sc = new Scanner(System.in);

        String teamname[]=new String[20];
        int points[][]=new int[5][5];
        for(int i=1;i<=2;i++)
        {
         System.out.println("Enter the name of team "+i);
         teamname[i] = sc.next();
        }
       
        for(int i=1;i<=4;i++)
        {
         for(int j=1;j<=2;j++)
        {
         System.out.println("Enter quarter "+i+" points for "+teamname[j]);
         points[i][j] = sc.nextInt();
        
        }
        }
        outputResults(teamname,points);
    }


    public static void outputResults(String[] teamname,int [][]points)
    {
        int sum[]=new int[5];
        System.out.println("Game Summary");
        System.out.println("------------");
       
        for(int j=1;j<=2;j++)
        {
        System.out.print(" "+teamname[j]+ " : ");
        for(int i=1;i<=4;i++)
        {
            System.out.print(points[i][j]+" ");
            sum[j]+=points[i][j];
         }
        }
        for(int j=1;j<=2;j++)
        {
        System.out.print(" "+teamname[j]+ " : "+sum[j]);
        }
    }
   
}

Output


Enter the name of team 1
Ravens
Enter the name of team 2
Steelers
Enter quarter 1 points for Ravens
14
Enter quarter 1 points for Steelers
0
Enter quarter 2 points for Ravens
21
Enter quarter 2 points for Steelers
0
Enter quarter 3 points for Ravens
3
Enter quarter 3 points for Steelers
0
Enter quarter 4 points for Ravens
10
Enter quarter 4 points for Steelers
0
Game Summary
------------

Ravens : 14 21 3 10
Steelers : 0 0 0 0
Ravens : 48
Steelers : 0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote