Results 1 to 8 of 8
Thread: Array help
- 12-23-2010, 03:20 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 5
- Rep Power
- 0
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.
- 12-23-2010, 05:13 PM #2
Member
- Join Date
- Dec 2010
- Posts
- 27
- Rep Power
- 0
What errors are you getting?
- 12-23-2010, 07:43 PM #3
Member
- Join Date
- Dec 2010
- Posts
- 5
- Rep Power
- 0
In the yearly stats method the bit were it says double average = the year 2008 bit and 2009 is underlined
- 12-24-2010, 09:20 AM #4
Member
- Join Date
- Dec 2010
- Posts
- 27
- Rep Power
- 0
You should change
for (int i=0; i>year.length; i++)
to
for (int i=0; i<year.length; i++),
I think.
- 12-24-2010, 05:09 PM #5
Member
- Join Date
- Dec 2010
- Posts
- 5
- Rep Power
- 0
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 [code] above your pasted code and the tag [/code] below your pasted code like so:
Best of luck!Java Code:[code] // your code goes here // notice how the top and bottom tags are different [/code]
- 12-25-2010, 01:45 AM #7
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
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..
- 12-25-2010, 03:34 AM #8
Senior Member
- Join Date
- Dec 2010
- Posts
- 165
- Rep Power
- 3
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.
at least now it compiles. As for logic of the code, you have to do yourself.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 { .....
Similar Threads
-
Variable of an object in an array compared to an element of another array?
By asmodean in forum New To JavaReplies: 23Last Post: 09-07-2010, 08:12 PM -
Trying to make an array list // inserting an element to middle of array
By javanew in forum New To JavaReplies: 2Last Post: 09-06-2010, 01:03 AM -
Convert Char Array to String Array
By Mayur in forum New To JavaReplies: 8Last Post: 10-12-2009, 11:41 AM -
Array length and printing out uninitialized array.
By nicolek808 in forum New To JavaReplies: 4Last Post: 09-10-2009, 09:12 AM -
How to add an integer to a array element and the store that backinto an array.
By Hannguoi in forum New To JavaReplies: 1Last Post: 03-31-2009, 06:40 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks