Questions about arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jimgym1989
    New Member
    • Sep 2008
    • 30

    Questions about arrays

    Code:
    import java.io.*;
    import java.util.*;
    
    public class ArrayNo9 {
     
     static Scanner console = new Scanner(System.in);
        public static void main(String[]args) {
         
         int[][] inStock = new int[10][4];
         //inStock[0] = new int[10];
         int[] alpha = new int[20];
         int[] beta = new int[20];
         int[] gamma = {11,13,15,17};
         int[] delta = {3,5,2,6,10,9,7,11,1,8};
    copyGama(inStock,gamma);
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    Your thread title is "Questions about arrays", but there are no questions here.

    Comment

    • jimgym1989
      New Member
      • Sep 2008
      • 30

      #3
      Questions about arrays..

      Code:
      import java.io.*;
      import java.util.*;
      
      public class ArrayNo9 {
       
       static Scanner console = new Scanner(System.in);
          public static void main(String[]args) {
           
           int[][] inStock = new int[10][4];
           int[] alpha = new int[20];
           int[] beta = new int[20];
           int[] gamma = {11,13,15,17};
           int[] delta = {3,5,2,6,10,9,7,11,1,8};
      
           copyGama(inStock,gamma);
      }
      public static void copyGama(int[][]a,int[]b)
          {
           int index,c,i,answer;
           System.out.print("\nCopy Gama\n");
           for(i = 0;i<a.length;i++) // upto 10 rows
           {
           for(c = 0;c<b.length;c++)
           {
           	a[i][c] = b[c];
           	System.out.print(" "+a[i][c]);
           }
           if(c==4){
           System.out.println();  // every 4th element must be printed to another line
           }
          }
          }
      }
      how can i make each row of the array multiplied by 3?
      example the 1st row is = 11,13,15,17
      2nd row is = 33, 39,45 51
      3rd row is = 99, 117 , 135, 153
      and so on and so forth...this is upto 10th row..you can see it on my code..
      i already tried my best..but got know idea at all..

      Comment

      • Nepomuk
        Recognized Expert Specialist
        • Aug 2007
        • 3111

        #4
        Dear jimgym1989, when Ganon11 said
        Originally posted by Ganon11
        there are no questions here.
        he didn't mean: Post a completely new thread with the question.

        You should have just added your question in a reply (using the post reply button at the bottom of each thread).

        I have merged your two threads, to make sure the answers go to the right place.
        Originally posted by jimgym1989
        how can i make each row of the array multiplied by 3? [...]
        you can see it on my code..
        i already tried my best..but got know idea at all..
        Where have you tried multiplying by with 3? I can't see it anywhere in your code.

        By the way, when your code reaches line 28, c will always be the same, as it's reset to 0 at the beginning of the nested for loop and it doesn't reach line 28 until the loop is ended.

        Greetings,
        Nepomuk (Moderator)

        Comment

        • jimgym1989
          New Member
          • Sep 2008
          • 30

          #5
          Originally posted by Ganon11
          Your thread title is "Questions about arrays", but there are no questions here.
          just understand the code...

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by jimgym1989
            just understand the code...
            That is not the way to ask questions; help us to help you because most of us are
            not mind readers. If you are, read my thoughts.

            kind regards,

            Jos (moderator)

            ps. Read the 'help' link near the top of this page.

            Comment

            • jimgym1989
              New Member
              • Sep 2008
              • 30

              #7
              Originally posted by JosAH
              That is not the way to ask questions; help us to help you because most of us are
              not mind readers. If you are, read my thoughts.

              kind regards,

              Jos (moderator)

              ps. Read the 'help' link near the top of this page.
              we are all mature so better use your common sense!!
              take care...

              Comment

              • jimgym1989
                New Member
                • Sep 2008
                • 30

                #8
                Originally posted by jimgym1989
                Code:
                import java.io.*;
                import java.util.*;
                
                public class ArrayNo9 {
                 
                 static Scanner console = new Scanner(System.in);
                    public static void main(String[]args) {
                     
                     int[][] inStock = new int[10][4];
                     int[] alpha = new int[20];
                     int[] beta = new int[20];
                     int[] gamma = {11,13,15,17};
                     int[] delta = {3,5,2,6,10,9,7,11,1,8};
                
                     copyGama(inStock,gamma);
                }
                public static void copyGama(int[][]a,int[]b)
                    {
                     int index,c,i,answer;
                     System.out.print("\nCopy Gama\n");
                     for(i = 0;i<a.length;i++) // upto 10 rows
                     {
                     for(c = 0;c<b.length;c++)
                     {
                     	a[i][c] = b[c];
                     	System.out.print(" "+a[i][c]);
                     }
                     if(c==4){
                     System.out.println();  // every 4th element must be printed to another line
                     }
                    }
                    }
                }
                how can i make each row of the array multiplied by 3?
                example the 1st row is = 11,13,15,17
                2nd row is = 33, 39,45 51
                3rd row is = 99, 117 , 135, 153
                and so on and so forth...this is upto 10th row..you can see it on my code..
                i already tried my best..but got know idea at all..
                that was my question

                Comment

                • Nepomuk
                  Recognized Expert Specialist
                  • Aug 2007
                  • 3111

                  #9
                  Originally posted by jimgym1989
                  that was my question
                  ...which I had to move here. Listen, from just posting a bit of code (which was all that was here when Ganon11 asked), nobody can guess that you want to multiply lines by three. You may want to add things up or swap the values or anything else.

                  Now, as Jos said, we can't read your mind. We are happy to help you, but we're doing this for free and because we're all nice people. So if someone doesn't understand your question, try to put it in other words.

                  In case you haven't done so already, please read the Posting Guidelines, especially the Sections about How to ask a question and Things that are generally unacceptable. Saying things like
                  Originally posted by jimgym1989
                  just understand the code...
                  or
                  Originally posted by jimgym1989
                  we are all mature so better use your common sense!!
                  imply that you are accusing us of being dumb or immature. I would call that a breach of the rule
                  Originally posted by Things that are generally unacceptable
                  Personal Insults or Attacks
                  and am hereby giving you an official warning (your second one by the way). Keep to the rules from now on and we'll solve your problem with you. Continue like this however and it will have consequences.

                  Greetings,
                  Nepomuk (Moderator)

                  Comment

                  • jimgym1989
                    New Member
                    • Sep 2008
                    • 30

                    #10
                    Originally posted by Nepomuk
                    ...which I had to move here. Listen, from just posting a bit of code (which was all that was here when Ganon11 asked), nobody can guess that you want to multiply lines by three. You may want to add things up or swap the values or anything else.

                    Now, as Jos said, we can't read your mind. We are happy to help you, but we're doing this for free and because we're all nice people. So if someone doesn't understand your question, try to put it in other words.

                    In case you haven't done so already, please read the Posting Guidelines, especially the Sections about How to ask a question and Things that are generally unacceptable.
                    Saying things like or imply that you are accusing us of being dumb or immature
                    .
                    I would call that a breach of the rule and am hereby giving you an official warning (your second one by the way).
                    Keep to the rules from now on and we'll solve your problem with you. Continue like this however and it will have consequences.

                    Greetings,
                    Nepomuk (Moderator)
                    ok!! sorry!! it depends on what your thinking!!
                    but no offense!!
                    :-)
                    When was the first warning master? i can't remember it.. sorry..
                    please forgive me..all you say was not my intention..but ok! there is nothing I can't do about that because your the Administrator.. Sorry!!
                    Last edited by jimgym1989; Sep 12 '08, 01:18 PM. Reason: i forgot something...

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32634

                      #11
                      Originally posted by jimgym1989
                      ok!! sorry!! it depends on what your thinking!!
                      but no offense!!
                      :-)
                      ...
                      A more reliable way of not causing offense, is not to say the offensive thing in the first place.
                      Originally posted by jimgym1989
                      ...
                      When was the first warning master? i can't remember it.. sorry..
                      ...
                      While there was no official warning given before, you have previously been called to attention on not following the site rules (See post #2 of I Have A Class And Method Problems....). It surprises me not at all that you wouldn't remember. You don't seem to have the capacity to pay any attention to what you're being told, your focus concentrating so exclusivley on yourself.
                      Originally posted by jimgym1989
                      ...
                      please forgive me..all you say was not my intention..but ok! there is nothing I can't do about that because your the Administrator.. Sorry!!
                      If it was not your intention to commit the offenses, then I should advise you to get a bit more control of yourself. I can't see who should be responsible for this if not yourself.

                      As for the administrator jibe. Nepomuck is a moderator, so I assume he treats this comment with the derision it deserves.
                      I however, AM an administrator, and I can confirm that none of us intends to put up with any more of your petulant outbursts. To put this in the plainest English I can, "Either desist or your account will be suspended. Further infringements after that will result in a permanent ban on your account."

                      Comment

                      • Nepomuk
                        Recognized Expert Specialist
                        • Aug 2007
                        • 3111

                        #12
                        Originally posted by jimgym1989
                        When was the first warning master? i can't remember it.. sorry..
                        As NeoPa pointed out, I called you to attention in your I Have A Class And Method Problems.... thread. I do admit however, that it wasn't clearly an official warning, so sorry for not being clear earlier.
                        Originally posted by jimgym1989
                        please forgive me..all you say was not my intention..but ok!
                        I can't speak for the others, but I'm not resentful and if you behave respectfully and keep to the rules from now on, everything will be fine. If you don't however... well, just read NeoPa's reply.

                        Now, back to your question: Please note what I said in reply #4:
                        Originally posted by Nepomuk
                        Where have you tried multiplying by with 3? I can't see it anywhere in your code.

                        By the way, when your code reaches line 28, c will always be the same, as it's reset to 0 at the beginning of the nested for loop and it doesn't reach line 28 until the loop is ended.
                        I assume you have a third function to do that job? Can we please see it? If you don't have it yet, can you try to write it and, if you have problems, show us that? Because we're not going to write it for you.

                        Greetings,
                        Nepomuk

                        Comment

                        • jimgym1989
                          New Member
                          • Sep 2008
                          • 30

                          #13
                          by the way..I already solved the problem!
                          tnx for your effort..
                          :)

                          Comment

                          • Nepomuk
                            Recognized Expert Specialist
                            • Aug 2007
                            • 3111

                            #14
                            Originally posted by jimgym1989
                            by the way..I already solved the problem!
                            tnx for your effort..
                            :)
                            That's good. If you need any further help (with this or any other task), feel free to ask - but please keep to the site rules.

                            Greetings,
                            Nepomuk

                            Comment

                            Working...