AP Notes, Outlines, Study Guides, Vocabulary, Practice Exams and more!

need help with an arrays program

2 posts / 0 new
Last post
et_thehuman's picture
Joined: Dec 2007
need help with an arrays program

this is the task
1.instantiate an array to hold integer test scores
2.determine and print out the total number of scores
3.determine whether there are any perfect scores (100) and if so print student numbers (who received these scores)
4.print out only the scores that are greater or equal to 80
5.calculate the percentage of students that got scores of 80 or above (and print out)
6.calculate the average of all scores (and print out)

heres the code that i came up with

int [] scores = {79, 87, 94, 82, 67, 100, 98, 87, 81, 74, 91, 59, 97, 62, 78, 66, 83, 75, 88, 94, 63, 44, 100, 69, 87, 99, 76, 72};
int total=scores.length;
System.out.println("The total number of scores is: "+total);
for (int i=0;i<=scores.length;i++)

step 2 is as far as i got
i got stuck at step 3, i cant figure out how to do that
reply plz, ty

Hunterbender's picture
Joined: Nov 2007

for(int i = 0; i < total; i++)
if(scores [i] == 100)
System.out.println("Student" + i);
4 is just same as above. Rather than ==, do > = 80. Also, keep an int counter for part 5.
int counter = 0;
for(int i = 0; i < total; i++)
if(scores [i] == 100){
System.out.println("Student" + i);
count ++;}
5. err. return counter/length
6 same thing sorta. For loops through the who thing and do something like
int total += scores[i]
then divide it by the length


Need Help?

We hope your visit has been a productive one. If you're having any problems, or would like to give some feedback, we'd love to hear from you.

For general help, questions, and suggestions, try our dedicated support forums.

If you need to contact the Course-Notes.Org web experience team, please use our contact form.

Need Notes?

While we strive to provide the most comprehensive notes for as many high school textbooks as possible, there are certainly going to be some that we miss. Drop us a note and let us know which textbooks you need. Be sure to include which edition of the textbook you are using! If we see enough demand, we'll do whatever we can to get those notes up on the site for you!