comment appliquer un calcul en fonction du tableau ?
Bonjour a tous ,
Je suis encore un novice en java, et j'ai un devoir à faire dessus. à un moment donnée dans mon programme, je dois appliquer un prix en fonction des nombres dans un tableau que j'ai rempli precedement (noté poids[]).
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
y=0;
while (y < cpt){
if (poids[y]<=8){
tarif= tarif+tpchien;
}
else if (poids[y]<=23){
tarif= tarif+pchien;
}
else if (poids[y]<=40){
tarif= tarif+mchien;
}
else if (poids[y]<=55){
tarif= tarif+gchien;
}
else if (poids[y]>=56){
tarif= tarif+tgchien;
}
y++;
} |
J'ai ensuite le message d'erreur suivant :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
at fraisejours.main(fraisejours.java:44)
(la ligne en question est en gras)
comment faire pour appliquer un tarif en fonction des données du tableau ?