Results 1 to 2 of 2
- 03-31-2009, 06:31 AM #1Member
- Join Date
- Mar 2009
- Rep Power
How to add an integer to a array element and the store that backinto an array.
Hello everyone i'm new to java and never had any computer programming before.
and i'm current doing a project for school and i have a few question on the coding of an array.
Here is part of my program.
int counts = new int [maxHeads + 1]; for(int i = 0; i <counts.length; i++) counts[i] = counts[i] * (int)((maxLength/maxCount) + 0.5); /* This is what i wanted to do "Now multiply each value in the counts array by the MAX length we want for bars (maxLength) and divide by the largest value found (“maxCount”). Remember the limitations of multiplication and division for integer variables. You will need to cast the integers to float or double for the calculation and cast the result back to integer to [COLOR="Red"][B][U]update the value in each counts array element[/U][/B][/COLOR]. It is also a good idea to add 0.5 to the float or double value before casting it back to an integer. That causes the code to round-off the value during the conversion rather than truncate the value." */
- 03-31-2009, 07:40 AM #2
please be more specific. what is your problem? Do you not know how to add, subtract using java arrays?
i have a few question on the coding of an array.USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
- By Unknown in forum New To JavaReplies: 6Last Post: 03-21-2010, 11:40 PM
- By lavanyashastri in forum New To JavaReplies: 1Last Post: 02-21-2009, 07:02 AM
- By Preethi in forum New To JavaReplies: 5Last Post: 09-25-2008, 05:23 AM
- By revathi17 in forum New To JavaReplies: 2Last Post: 12-31-2007, 09:44 AM
- By mew in forum New To JavaReplies: 5Last Post: 12-03-2007, 06:26 PM