Results 1 to 8 of 8

Thread: Array help

  1. #1
    jamiem is offline Member
    Join Date
    Dec 2010
    Posts
    5
    Rep Power
    0

    Default Array help

    i have a problem with my code the problem i am stuck with is the method yeraly stats were i am asked to take the value of two arrays of integers represting the amount produced for each year and display the average amount produced for each shift team was wondering if you could help and tell my what part of my code is wrong or missing?
    Last edited by jamiem; 12-27-2010 at 04:49 PM.

  2. #2
    demonick is offline Member
    Join Date
    Dec 2010
    Posts
    27
    Rep Power
    0

    Default

    What errors are you getting?

  3. #3
    jamiem is offline Member
    Join Date
    Dec 2010
    Posts
    5
    Rep Power
    0

    Default

    In the yearly stats method the bit were it says double average = the year 2008 bit and 2009 is underlined

  4. #4
    demonick is offline Member
    Join Date
    Dec 2010
    Posts
    27
    Rep Power
    0

    Default

    You should change

    for (int i=0; i>year.length; i++)

    to

    for (int i=0; i<year.length; i++),
    I think.

  5. #5
    jamiem is offline Member
    Join Date
    Dec 2010
    Posts
    5
    Rep Power
    0

    Default

    I did have that done but then I think the yearlystats 2008 and 2009 in the main method were underlined?

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by jamiem View Post
    I did have that done but then I think the yearlystats 2008 and 2009 in the main method were underlined?
    Perhaps you should show your updated code -- using code tags please and post the actual error messages. Put comments in your code to show us where the errors are occurring.


    To use code tags, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.

    Another way to do this is to manually place the tags into your code by placing the tag [cod&#101;] above your pasted code and the tag [/cod&#101;] below your pasted code like so:

    Java Code:
    [cod&#101;]
      // your code goes here
      // notice how the top and bottom tags are different
    [/cod&#101;]
    Best of luck!

  7. #7
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    ran through this whole question expecting decent formatting.... oh then fubarble had to tell you in the end...nobody does unformatted code unless they are seriouly bored, that never happens by the way..

  8. #8
    JavaHater is offline Senior Member
    Join Date
    Dec 2010
    Posts
    165
    Rep Power
    4

    Default

    next time, show what errors you have after compilation. I spent the time to compile your code, and found that most of them is declaration errors. If you want to use year2008 or year2009 in other functions, then don't declare them inside main(). Make them "globally" available.
    Java Code:
    public class Assignment //start class               
    {                                                   
    
            private static  int[] year2008=new int [10]; //2008 array
            private static  int[] year2009=new int [10]; //2009 array
    
            public static void main (String[]args) //start main method
            {                                                         
    .....
    at least now it compiles. As for logic of the code, you have to do yourself.

Similar Threads

  1. Replies: 23
    Last Post: 09-07-2010, 08:12 PM
  2. Replies: 2
    Last Post: 09-06-2010, 01:03 AM
  3. Convert Char Array to String Array
    By Mayur in forum New To Java
    Replies: 8
    Last Post: 10-12-2009, 11:41 AM
  4. Array length and printing out uninitialized array.
    By nicolek808 in forum New To Java
    Replies: 4
    Last Post: 09-10-2009, 09:12 AM
  5. Replies: 1
    Last Post: 03-31-2009, 06:40 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
  •