I have an assignment and I am confused by the examples the book gives. I have to: 1. Prompt user for number of tests to be entered
2. Initialize array to hold number of test scores entered
3. Main method calls for inputData Method (passing array as argument)
4. Main Method calls for outputData Method (passing array as arg)
Here is what I have so far. Don't laugh. I am using samples from the book but am having problems piecing it all together. The book kinda sucks for samples.
Java file featuring arrays.
public class XXX Tests
User inputs test scores.
public static void main(String args)
System.out.println("Enter Number of Tests Between 1 and 5:");
Scanner Keyboard = new Scanner)System.in);
n1 = keyboard.nextInt();
if ((n1 < 0 ) || (n1 > 5 )
System.out.println("Invalid number entered, please try again:");
while ((n1 < 0) || (n1 > 5);
//Declare new array
double testscores = new double;
double sum, average;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter test scores:");
sum = 0
for (index = 0; index < 5; index++)
testscores[index] = keyboard.nextDouble();
sum = sum + testscores[index];
average = sum/5;
System.out.println("The average test score is:");
System.out.println("Hope this helped!");
09-01-2005, 08:37 AM
what error are you getting?
09-01-2005, 08:41 AM
It won't even compile actually. I know the array stuff is wrong. My book samples have me all confused.