Hi I am creating a program that needs to take 10 grades and give you the average, lowest, and highest grades. It needs to use arrays. Have I used arrays or used they correctly so far? Where do I need to put the grades in at? I have written part of the program but dont know what to do can anyone help?
public class Arrayofscores
{
public static void main(String args[])
{
int [] scores = new int[10];
int smallest, highest,total=0;
double average =0.0;
{
//lowest score
smallest = scores[0];
for (int i = 1; i <= scores.length-1;i++)
if (scores[i] < smallest)
smallest = scores[i];
System.out.println("The lowest score is : " + smallest);
//highest score
highest = scores[0];
for (int i = 1; i <= scores.length-1;i++)
if (scores[i] > highest)
highest = scores[i];
System.out.println("The highest score is : " + highest);
//average score
for (int i = 0; i<=scores.length-1;i++)
total = total + scores[i];
average = total/10.0;
System.out.println("The average score is : " + average);
}
}
}