CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2015
    Posts
    2

    Input Array and Search Array

    Hey guys, I know I am going to ask for a lot of help here but I am working on simple program that will do the following:

    A dialogue box will pop up asking the user to input a state name or abbreviation. The program will then search the arrays and return a value. I also need to input and store the values. I need to be able to input a persons name and a list of states the user is registered in. So example:

    Enter State: [ ]
    user input: NY

    Return:

    The following people are registered NY:

    Alex [Extension: 101]
    Brian [Extension: 202]

    *it would be great if it used a nice organized table to display this*

    I also want to be able to input and edit the arrays:

    Example:

    Enter Persons Name:
    user input: Alex

    Enter Alexs' Registered States:
    user input: NY
    user input: TX

    I know what to do I just don't know how to do it.
    I know how to search a string array but I don't know how to search multiple arrays at once.
    I also don't know how to store and edit arrays based on user input. I am unsure if i need to do a loop to search for the string in the arrays or not.

    Any help will be greatly appreciated! Thanks.

  2. #2
    Join Date
    Aug 2015
    Posts
    5

    Re: Input Array and Search Array

    For the first part use JDialog. With Eclipse you can use WindowBuilderPro to design the windows easily with JDialog but you will need to understand Java Swing fairly well so you may as well hit the tutorials.
    For data you should use JDBC and there are a lot of tutorials. This part sounds daunting, it's not though so just Google an example. Never recreate the wheel there is great framework in place so use it.

    I encourage you to start from the beginning not such a hard program but each person is driven differently. Java Oracle Tutorials is where I started.

  3. #3
    Join Date
    Aug 2015
    Posts
    2

    Re: Input Array and Search Array

    Thanks. Also, I can't put the list of arrays in the code, I have to use a database?

  4. #4
    Join Date
    Sep 2015
    Posts
    10

    Cool Re: Input Array and Search Array

    Code:
    Arrays of arrays
    
    package com.ack.learning;
    
    public class ArraysOfArrays {
      public static void main( String[] args ) {
        // creates an array of integer arrays
        // note that the column sizes are jagged, that is,
        // of different sizes
        int[][] matrix =
            {
              {1, 2, 4},
              {2, 4},
              {5, 6, 7, 8, 9}
            };
    
        // cycle through the array, and output its contents
        for( int i = 0; i < matrix.length; i++ ) {
          for( int j = 0; j < matrix[i].length; j++ ) {
            System.out.println( "matrix[" + i + "][" + j + "] = " + matrix[i][j] );
          }
        }
    
        // specify array of strings
        String[][] anotherMatrix =
            {
              {"hello"},
              new String[]{"hello", "world"}, /* note, embed new arrays here */
              {"the", "quick", "brown", "fox"}, /* note, comma can be added here */
            };
      }
    }
    Arrays of arrays

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured