Question: How do I change my 2D arrays to array lists? This is the code I have: import java.util.Scanner; import java.text.DecimalFormat; class BattingAverageApp{ public static void

How do I change my 2D arrays to array lists? This is the code I have:

import java.util.Scanner; import java.text.DecimalFormat; class BattingAverageApp{ public static void main(String []arg){ Scanner sc = new Scanner(System.in); System.out.println("Welcome to the Batting Average Calculator. "); while(true){ System.out.print("Enter the number of batters: "); int n = sc.nextInt(); System.out.println(" 0 = out, 1 = single, 2 = double, 3 = triple, 4 = home run"); int [][]batterScore = new int[n][3]; for(int i=0;i 0){ count ++; } sum += batterScore[i][j]; } DecimalFormat numFormat = new DecimalFormat("#0.000"); System.out.println("Batter " + (i+1) + " average: " + numFormat.format(((double)count)/3) + " \t\tSlugging percent: " + numFormat.format(((double)sum)/3)); } System.out.print(" Another Batter? (y/n): "); String s = sc.next(); if(s.charAt(0) == 'n' || s.charAt(0) == 'N'){ break; } } } }

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!