r/javahelp • u/[deleted] • Apr 16 '16
why wont this average program work?
why wont it show the average what do i need to change in my for loop? if i use for each loop it works but i dont wanna use a for each loop.
0
Upvotes
2
Apr 16 '16
You know integers are whole numbers? You'll want to use a float or double.
You also need to cast it to a floating point e.g.
float avg = (float) (1+2+3+4+5)/5also you need to use numbers[i], not i
1
u/[deleted] Apr 16 '16
nm i got it had to use numbers[i]. duh