Results 1 to 3 of 3
  1. #1
    javanewbie is offline Member
    Join Date
    Jun 2008
    Location
    Australia
    Posts
    43
    Rep Power
    0

    Unhappy Algorithm statement in my Java codes

    Good day everyone.

    I'm still confused on how the process/algorithm will work here:

    Java Code:
    // i've added + 1 to have an initial value of 1 (?)
    // <confused>
    int aiNumbers[][] = new int[Integer.parseInt(args[0])+ 1]
    [Integer.parseInt(args[1]) + 1];
    
    // <confused>
    if(args[0].equals("0") || args[1].equals("0")) {
          System.out.println("0");
    } 
    else {
           
           // <confused> sorry, im a newbie.
           for(int iCtr=1;iCtr < aiNumbers.length; iCtr++) {
                    	
                  for(int iCtr2=1;iCtr2 < aiNumbers[iCtr].length; iCtr2++) {
                            
                         aiNumbers[iCtr][iCtr2] = iCtr * iCtr2;
    	             System.out.print(aiNumbers[iCtr][iCtr2] + " ");
                  }
    	      System.out.println("");
            }
    }
    Sorry Eranga. I still don't know how the process start and I don't even know how should I describe the process.

    Would someone help me on making good algorithm statements here?



    By the way, this code allows two arguments to be inputted by user to display like a 'multiplication table' depends on the 2 inputs.
    Here I used multidimensional arrays.


    I've tried simplier codes without arrays. But we are required to do it in a array.


    :confused:

  2. #2
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    By the way, this code allows two arguments to be inputted by user to display like a 'multiplication table'
    describe what's that two arguments to be added at runtime...
    What's the model of your multiplication table?

    You must idendify what should be used for the row and the column.
    freedom exists in the world of ideas

  3. #3
    javanewbie is offline Member
    Join Date
    Jun 2008
    Location
    Australia
    Posts
    43
    Rep Power
    0

    Default

    Ok here's the program works.

    First, the user will be ask for 2 inputs using commandline arguments.

    Then the program will display something like this:
    1st no: 2 (user input)
    2nd no: 5 (user input)

    Display:
    1 2 3 4 5
    2 4 6 8 10




    I have no problems regards to the validation on how many inputs are required in the program.



    With those codes, how can you describe a statement with a program like this?

    1st no: 8 (user input)
    2nd no: 2 (user input)

    Display:
    1 2
    2 4
    3 6
    4 8
    5 10
    6 12
    7 14
    8 16

Similar Threads

  1. Replies: 9
    Last Post: 06-25-2008, 05:48 AM
  2. How to get error codes using java program
    By kasipandian in forum Web Frameworks
    Replies: 10
    Last Post: 05-25-2008, 06:00 PM
  3. Soundex Algorithm Implementation in Java
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-12-2008, 09:40 PM
  4. Using Java To Implement RSA Algorithm
    By Floetic in forum New To Java
    Replies: 3
    Last Post: 04-01-2008, 12:56 AM
  5. Help with algorithm in java
    By coco in forum AWT / Swing
    Replies: 1
    Last Post: 08-01-2007, 07:45 AM

Posting Permissions

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