For our programming assignment we have to ask the user for a Region Name and the statitics (integers) of that region we have to associate the integers with the Region Name and we have to be able to create multiple regions this is what I got so far lost as to what to do next Where I am confused is we have to call all the Regions the user has made Region A, Region B, Region C, then the user will select a Region from the list let’s say Region A then we must print the integers associated with Region A Example Region A contains integers {12,3,6,8]
ArrayList<String> regions = new ArrayList<String>();
System.out.print(" Enter Region to Add to List: ");
regionName = keyb.nextLine();
keyb.nextLine();
regions.add(regionName);
System.out.printf(" Enter Data for %s: " ,regionName);
regionData = keyb.nextLine();
String[] reg_Values = regionData.split(" ");
double[] reg_DoubleValues = new double[reg_Values.length];
double num;
for (int i=0; i<reg_Values.length; i++)
{
num = Double.parseDouble( reg_Values[i] );
reg_DoubleValues[i] = num;
System.out.print(reg_DoubleValues[i]);
}
System.out.println();
It sounds like you need an Hashmap, or a key value pair collection.
Providing that the regions are unique.
Or
Or
create a
Regionclass, and have a composition ofList<Integer>.Like so: