I am attempting my first final project in Java, and am having a time of it. I am supposed to make a program that asks the user for a test number, gets the text file for the respective test number that I've created, and display the test to the user. The user takes the test, then it is graded and written to another text file. I have no idea how to work with files. They weren't even covered in this semester at all, and my professor has been of zero assistance this semester (it's online, big mistake). I have attempted to follow a guide I found to get it to work so that I could hopefully wrap my head around it, but am getting errors. I may just be making stupid mistakes because this is making me flustered, and I'll come back to it later once I've cooled down, but in the meantime, if anyone could tell me what is wrong, or even give me advice on how to do the file handling so I can delete this and start over, that would be fantastic. Under the code is the full assignment, if anyone is curious.

import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;

public class FinalProject {

    public static void main(String[] args) throws IOException{

        String fileName = new File("12345.txt").getAbsolutePath();


            ReadFile file = new ReadFile(fileName);
            String[] aryLines = file.OpenFile();
            int i;
            for(i=0; i < aryLines.length; i++){

        catch(IOException e){


        WriteFile data = new WriteFile(fileName, true);
        Test test = new Test();


class Test{

    private Scanner input = new Scanner(System.in);
    private int testCode, studentID;
    private String studentName;

    private int getStudentID() {

        System.out.println("What is your student ID?");
        studentID = input.nextInt();
        return studentID;


    private void setStudentID(int studentID) {

        this.studentID = studentID;

    private String getStudentName() {

        System.out.println("What is your name?");
        studentName = input.nextLine();
        return studentName;


    private void setStudentName(String studentName) {

        this.studentName = studentName;

    private int getTestCode() {

        System.out.println("What is the ID of the test you wish to take?");
        testCode = input.nextInt();
        return testCode;


    private void setTestCode(int testCode) {

        this.testCode = testCode;


    public void test(){


    public void getStudentInfo(){




class WriteFile{

    private String path;
    private boolean appendFile = false;

    public void WriteFile(String filePath, boolean appendValue){
        path = filePath;
        appendFile = appendValue;

    public void writeToFile(String textLine) throws IOException {

        FileWriter write = new FileWriter(path, appendFile);
        PrintWriter printLine = new PrintWriter(write);
        printLine.printf("%s" + "%n", textLine);


class ReadFile {

    private String path;

    public void readFile(String filePath){
        path = filePath;

    public String[] OpenFile() throws IOException{

        FileReader reader = new FileReader(path);
        BufferedReader textReader = new BufferedReader(reader);

        int numberOfLines = readLines();
        String[] textData = new String[numberOfLines];

        int i;

        for(i=0; i < numberOfLines; i++){
            textData[i] = textReader.readLine();

        return textData;

    int readLines() throws IOException{

        FileReader readFile = new FileReader(path);
        BufferedReader bf = new BufferedReader(readFile);
        String aLine;
        int numberOfLines = 0;

        while((aLine = bf.readLine()) != null){
        return numberOfLines;

A testing center needs a program to administer and grade its collection of tests. Your goal
for this project is to build a program that lets an individual enter a test code, take a test,
have the test graded, and view the testing results. The tests are stored in data files, and
the testing results are also stored in a data file. The program must read the test questions
from a file and then write the test results to another file.


The information you need to design and build your program is detailed below. Use it to
design an implementation in the form of a Java program. You can build your program with
a graphical user interface or with a text-based interface. Make sure your program properly
handles invalid and/or unexpected user input along with other Exceptions that may occur.
The look and feel of the user interface is up to you, as is the format of the data files.

The Quiz Files

Since the facility handles a large number of tests for various organizations, each test has
been identified using a unique, numeric code. The questions and answers for each test
will be stored in a text file whose name is the numeric code followed by a
dat extension.  For example, the file for test 12345 will be named 12345.dat. Each test file will hold
an unspecified number of true/false, multiple choice and fill-in-the-blank questions along
with the answer and, for multiple-choice questions, the set of possible answers the user can
choose from.  

The Student Use Case  

The testing center wants the program to function as follows. When the program starts,
the student will enter a student id, name, and test code. Assuming the code is valid, the
program instructs the student that the test is about to begin and asks the student to press
1 a key to begin. Once the test begins, each question is presented in sequence; the student
must answer a given question before advancing to the next.
When the test is complete, the program should display the test results, which should in-
clude the number of questions, the number answered correctly, the number of incorrect
answers, and the percentage correct. The results should be stored in a data file named
results.dat along with the student’s code, name, the test code, the date the test was
taken, and the test result details described above.

The Administrative Use Case

If, when the program starts, the user enters a special administrative code (come up with
one), the program will display a report showing, for each test taken, the name of the stu-
dent who took the test, the date the test was taken, the test code, and the percentage


You will be graded on whether or not the basic requirements are met, the quality of the
user interface, the quality of the code (the style, appearance, and best use of language
capabilities), and the quality of the documentation in the code to help make it easier to
follow.  The project is worth 200 points. Name your program FinalProject.java.  Also make
sure it includes a comment with your name, date, semester, and your student number at
the top. Also include at least one test file along with the results file. Compress the files you
submit into a single zip file and submit it within Blackboard on or before the due date of
December 14, 2017