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++)
System.out.println(scores);
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
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
6