i am having trouble with lets say i do not have any test scores and enter -1 there is an error of dividing by zero.
import java.util.Scanner;
public class myarray
{
public static void main(String args[ ])
{
Scanner kbd = new Scanner(System.in);
//total number of quiz scores possible in CS 200
final int MAX_SIZE = 10;
//Create (declare & instantiate) an int array of size 10, called: quizScores
int [] quizScores = new int[MAX_SIZE];
//Declare any other variable storage space needed by the program
int number;
int sum =0;
int ave =0;
int index;
int count =0;
/*Initialize the first 7 values to your quiz scores thus far in this course from user keyboard input
with a "do-while loop", sentinel value (-1) to stop loop,
and counter to keep track of how many values you have assigned to the array. */
do
{
System.out.println("Please enter your quiz scores. Enter -1 to quit.");
number = kbd.nextInt();
quizScores[count] = number;
if(quizScores[count] != -1)
{
count++;
}
}
while(number != -1 && count < quizScores.length);
/*Next, use the counter from the loop above to run a
"for loop" to sum your quiz scores. */
for(index = 0; index < count; index++)
{
sum = sum + quizScores[index];
}
/*Then, find the average score of your quizzes thus far
using the sum divided by the counter*/
ave = sum / count;
//Display (echo) your individual scores
for(index = 0; index < count; index++)
{
System.out.print(quizScores[index] + " ");
}
//Display the sum of the scores
System.out.println();
System.out.println("The sum of the quiz scores is: " + sum);
//Display the quiz score average
System.out.println("The average quiz score is: " + ave);
} //closing main method
} //closing class header