# urgent-map-pls help

This program takes the number of years and iterations to be runned. It then calculates the scores and stores them in the 2 dimensional score array based on the number of iterations and years.

For example,if the program is runned five times(iterations=3 and years=2), this could be the output.

score[year][iteration]

Iterations 1   Iteratons 2   Iterations 3
Years   1  2.666667       2.66667         2.66667
Years  2   3.2224           3.2221          3.4

so what i need to do is to find the percentage for the range based on years
For example, for year 1 , how many times got value between 2.6 to 2.7

For example, for year 2,how many times, got value between 3.2 to 3.3, 3.3 to 3.4

I just realized that the map below takes all the value in and does not consider it based on years..Is there a way to make the map think in years.

Map <Double,Integer> map=new HashMap<Double,Integer>();

for(int i=0;years+1;i++)
{
for(int j=0;j<iterations;j++){
Integer val=map.get(score[i][j]);
if(val==null)
map.put(score[i][j],1);

else
{
int newVal=val+1;
map.put(score[i][j],newVal);
}
}
}
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
use 2 maps, one for year 1 and the other for year 2.
If there could be even more years then use a list of maps
0
Author Commented:
how do implement the map in lists...

i tried like array..i get array..is there any example ,i could follow ... Map <Double,Integer> map[i]=new HashMap<Double,Integer>();

0
Author Commented:
sorry typo....i try like array..i get error...maybe, i not implementing right...is there any example to follow..thank you
0
Commented:
List<Map <Double,Integer>> maps= new ArrayList<Map <Double,Integer>>();
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
I get error ambigious...

I hope, it is ok if put ArrayList in front instead of List..When i compile,it is ok...

ArrayList<Map <Double,Integer>> maps= new ArrayList<Map <Double,Integer>>(years+1);
0
Author Commented:
Thanks a lot for the help :-)
0
Commented:
yes thats fine :)
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.