HELPP PLEASE

I need to write a program that does the following: store the quiz in my program, using a 2D array, include methods to calculate the average grade for each student + quiz, and write the calculated values to an output file.

Finally, the program should calculate the overall average and add it to the output file.

My program must include calls to these methods, as part of the task of reading in and processing the quiz dataset. I can use as many helper methods as I wish.

Detailed Description

Assume that 2D arrays are of the same length).

Must include the following methods

1. Write a method to read in the quiz scores dataset from a file. This method has a single

parameter, the TextFile file pointer variable that refers to the input data file. This method returns a 2D array of ints that holds the dataset, with rows representing students and columns representing quizzes. Note that the first two entries in the input file are integers specifying the number of students and the number of quizzes. The remainder of the file consists of the quiz scores, with the scores for each student grouped together as consecutive file entries.

2. Write a recursive method that computes and returns the sum of a 1D array of ints. The method has two parameters. The first is an integer specifying an initial index value in the array, and the other is the 1D array of ints.

3. Write a recursive method that computes and returns the sum of all the entries in a 2D array of ints. The method has two parameters, an integer specifying an index value for a row of the array, and the 2D array of ints. This method should compute each row sum by calling the method for the sum of a 1D array of ints.

4. Write a method that computes and returns the double-valued mean (the average) for a row

of a 2D array of ints. The row number and the 2D array are parameters.

5. Write a method that computes and returns a 2D array of ints that is the transpose of its single parameter, a 2D array of ints. Use this method to re-arrange the dataset so that rows correspond to quizzes, rather than students. Then you may use the same method to calculate a quiz average or a student average.

File Format: The sample input files for this assignment follow a standard format in which the first two entries in the file specify the number of students for which grades are included, and the number of quiz scores for each student. If N is the number of students and Q is the number of quizzes, the remainder of the file consists of N groups of Q values which are the quiz scores for one student. Within each group of Q values, the scores are in the same order: quiz1, quiz2, quiz3, ? There are no characters in the file other than integer numbers, spaces and new lines. Each quiz score is an integer value ranging from 0 to 10. Here are a few lines from the beginning of a sample input file.

Note that the supplied files do not contain comments.

11 // the number of students

4 // the number of quiz scores for each student

9 3 7 1 // quiz scores for the first student

2 8 10 10 // scores for the second student

7 0 9 9 // quiz1, quiz2, quiz3, quiz4 for the third student

Sample datasets:

25

5

10 7 10 7 6

7 9 6 9 5

6 7 7 7 5

7 8 9 10 9

8 8 9 9 9

8 4 6 8 8

4 9 6 8 5

5 3 5 6 9

9 6 8 9 9

7 8 1 3 7

6 7 6 6 3

6 6 10 10 7

8 6 7 8 7

9 7 6 5 6

10 10 8 7 10

10 10 8 8 10

8 6 6 4 7

7 4 9 8 5

5 5 4 6 9

5 6 6 7 8

9 10 8 9 8

10 9 5 2 3

7 8 9 8 6

6 6 7 7 10

9 8 10 10 9

8

3

4 5 9

5 9 5

9 10 7

8 9 9

5 7 7

7 7 5

3 7 5

7 8 8

11

9

7 9 8 9 5 5 6 9 7

4 9 8 7 6 5 4 8 8

8 8 8 4 7 9 10 7 8

9 10 9 9 9 10 9 8 10

10 6 8 6 5 8 6 9 9

5 6 6 5 6 7 6 7 5

8 10 4 9 10 9 8 5 4

5 8 7 5 6 7 7 9 5

8 9 10 9 7 8 8 5 7

8 9 7 7 7 5 9 6 7

9 7 10 4 7 10 9 9 5

I have no idea where to start, could someone please help me out?

I would really appreciate it, even if you can give me some pointers, especially with the 2D arrays.

Thanks

[4346 byte] By [jimmy123a] at [2007-11-27 7:57:36]
# 1
Use a more meaningful title in future. We know you want help, that is why you are here.Start small. Write a program that does one thing, reads in the values. Test it thoroughly and them move on.
floundera at 2007-7-12 19:39:28 > top of Java-index,Java Essentials,Java Programming...
# 2

Recommendation: Break this big problem down into little problems and solve the little problems one at a time. Your instructor has already done most of the breaking down for you, so start making your methods just as he/she suggested.

You need to know for future reference that our scope here is usually limited: we don't do homework here, nor do we teach java coding. We can help solve errors or try to answer specific questions. The work has to be done by you.

note number 2: You will get better help if you do some work yourself. Don't just throw up your hands and give up. Think. Write ideas on paper. Code. THEN come back if you have specific questions.

Good luck!

/Pete

petes1234a at 2007-7-12 19:39:28 > top of Java-index,Java Essentials,Java Programming...
# 3
Alright, sorry about that!I'll try and figure out as much as I can, and hopefully come to you with something more solid. Cheers
jimmy123a at 2007-7-12 19:39:28 > top of Java-index,Java Essentials,Java Programming...
# 4
> Alright, sorry about that!> I'll try and figure out as much as I can, and> hopefully come to you with something more solid. I have confidence that you will. Again, good luck./Pete
petes1234a at 2007-7-12 19:39:28 > top of Java-index,Java Essentials,Java Programming...
# 5

Hey,

Ok sooo.....I have tried to create an array where the variables can be stored. I have saved one dataset as input.txt in the same file.

Here is my program so far:

public class Assn3

{

TextFile inFile = new TextFile (true, "input.txt");

readFromFile(inFile);

//-

public array readFromFile(TextFile inputFile)

{

while(!(iFile.eof())

{ int studentNo = TextFile.inputFile.readInt();

TextFile.inputFile.skipWhiteSpace();

int quizNo = TextFile.inputFile.readInt();

for (i=1;i<=studentNo;i++)

{

for (j=1;j<=quizNo;j++)

{

int input = TextFile.inputFile.readInt();

//Stores the number appropriately in a 2D array

}

TextFile.inputFile.skipWhiteSpace();

}

}

}

Where I am stuck is that how do I actually assign the numbers into a 2D array. Any help?

Thanks

jimmy123a at 2007-7-12 19:39:28 > top of Java-index,Java Essentials,Java Programming...
# 6

> ...

> Where I am stuck is that how do I actually assign the

> numbers into a 2D array. Any help?

>

> Thanks

When posting code, please use code tags: it makes it so much easier to read. Here's how to use them:

http://forum.java.sun.com/help.jspa?sec=formatting

Have a look at this tutorial about arrays:

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html

Somewhere in the middle there's also an example how to use a multi-dimensional array.

Good luck.

prometheuzza at 2007-7-12 19:39:28 > top of Java-index,Java Essentials,Java Programming...