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.
so please help ty in advance
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." */