Results 1 to 2 of 2
- 12-26-2010, 02:04 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 1
- Rep Power
- 0
Storing Inputs in Two Linked Arrays
Hello everybody,
I am working in a small task that allow the user to enter the regions of any country and store them in one array. Also, each time he enters a region, the system will ask him to enter the neighbours of that entered region and store these regions.
My idea is each time the user enters the region, the system will store it in an arrya and each time he enters a region, the system will ask him to enter the neighbours of that region before he enters the second region and so on, and store these inputs in a second array under a pointer of the related entry in the first array.
what I did is just the beginning as follow:
import java.util.Arrays;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
String [] regionArray = new String[5];
for (int i = 0; i < regionArray.length; i++) {
System.out.print("Please enter the region: ");
regionArray[i] = kb.next();
//kb.nextLine(); // to get and discard the nextline token
}
System.out.print("You have entered: ");
System.out.println(Arrays.toString(regionArray));
}
}
For example, assume we have 4 regions: a, b, c, d, and a has two neighbours: b and d. In this case when the user enters the first region which is (a), he will be asked to enter its neighbours which are b and d, then he will be able to enter the second region which is b and so on.
the problem now, How can I genereated the second array and make it linked to the first array?
Please help me
- 12-26-2010, 02:21 PM #2
Senior Member
- Join Date
- Dec 2010
- Posts
- 165
- Rep Power
- 3
Similar Threads
-
help w/ storing/scanning numbers in arrays
By clemsontigers in forum New To JavaReplies: 15Last Post: 11-18-2010, 05:12 AM -
Arrays and use of null or empty inputs
By Desmond in forum New To JavaReplies: 6Last Post: 07-27-2010, 04:54 PM -
Arrays and Null inputs
By Desmond in forum New To JavaReplies: 4Last Post: 07-21-2010, 06:23 AM -
Need help storing arrays from a file
By arson09 in forum New To JavaReplies: 4Last Post: 03-08-2010, 04:11 PM -
Storing and managing huge arrays
By trust in forum Java SoftwareReplies: 2Last Post: 08-22-2009, 02:47 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks