Ok, so I need a bit of help on a small project I'm working on. Here's the run down of it: Write a Java program that allows the user to enter tests grades for yourself. The application should prompt the user to enter how many tests they wish to enter and enter the grades.
Here is the code:
import java.io.*;
public class Grades
{
public static void main(String [] args) throws IOException
{
// declare and consturct variables
String tests;
int grades;
float scores[] = new float[10];
BufferedReader dataIn= new BufferedReader(new InputStreamReader(System.in));
// prints prompts and get input
System.out.println("");
System.out.println();
System.out.println("\tThe score calculator");
System.out.println();
System.out.print("\t\tEnter how many test scores you wish to enter: ");
tests = dataIn.readLine();
grades = Integer.parseInt(tests);
for(int count = 0; count < grades; count++)
{
System.out.println("Enter the test");
tests = dataIn.readLine();
scores[10] = Float.parseFloat(tests);
}
}
}
The problem is the for loop part. When it asked for the first test, and gets the input, a message displays "Array is out of bounds" and I don't know how to fix that. Also, how do you dynamically allocate arrays in java?
Any advice would be most appreciated. Thank you :)