I am starting a program that is dealing with arrays. My issue, allowing a user to enter 'x' number of people into an array. How do I first allow them to enter the size of an array, and then enter strings (list) into that array. In addition to this, I need to specify the number of boxes of cookies sold by each person and keep a tally of the number of people selling cookies in each category (e.g. 1-10, 11-20...etc). Instead of having a number 100000, I want the user to enter that size, 'x'. I am still trying to piece it together, so please forgive the mess.
import java.util.Scanner; public class cookie { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x = 100; double saleCount[] = new double [x]; String[] girlScout = new String[100000]; System.out.print("Enter the number of scouts in your troop: "); int[] troopSize = new int[input.nextInt()]; for( int i = 0 ; i < troopSize.length ; i++ ){ System.out.print( "Enter scout name number" + (i+1) + ": " ); //String[] girlScout = new String[i]; girlScout[i] = input.next(); System.out.println(girlScout[i]); } //for(int i; i < girlScout.length; i++) //System.out.println("Test: " + girlScout[i] + " "); //for(input = 0 ; i <= input ; i++){ //} } }