Yes I have this in an array...

``````// Average Grade
for(int i = 0; i<10; i++);
{
}
``````

I am wanting to divide by 10 (where the 10 is) I know that it want let me but how would you divide a list of numbers that is in an array? or format it to?

Edited by Reverend Jim: Fixed formatting

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by roul47

Here is my complete program and it needs for the last part to devide all of the numbers in the array by 10.

``````public class Arrays
{
public static void main(String[] args)
{

// declare , initialize array
int[] scoreArray =  {50, 21, 32, 99, 102, 0, 88, 98, 101, 88 } ;
// print scores
for(int i = 0; i<10 ; i++ )
{
System.out.println("Score "+ i + " = " + scoreArray[i]);
}
// Highest Score
for(int i = 0; i<10; i++);
{
System.out.print("Hightest Score =" + scoreArray[4]);
}
// Lowest Score
for(int i = 0; i<10; i++);
{
System.out.print("Lowest Score =" + scoreArray[5]);
}
for(int i = 0; i<10; i++);
{
}
}
}
``````

Edited by Reverend Jim: Fixed formatting

Smells like homework to me!

Anyway.. Firstly, I think you need to understand what the for loop does. So, when you write for(int i=0; i<10; i++) {...}, you need to keep in mind that everything in the curly brackets is going to be executed 10 times.

I'm guessing you were asked to write a program that finds the lowest, highest and average of an array. So, just doing scoreArray[4] wouldn't be the best solution. You need to write a program that does the job.

To find the maximum of an array, you need to go through all the entries and compare their value with a "current max". Similarly with minimum.

The average is a tiny bit more complicated but if you do maximum and minimum properly I'm sure you'll find it easy :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.