Share
Explore BrainMass

Java Binary Search Tree Solution

Dear OTA -

I need a Java solution named TestGRE.java with a main method to test a Student Graduate Record Examination Score Managment System using BinarySearchTree java classes.

The solution should use the attached Student class.

Also, sample input that can be used is contained in the attached StudData.dat file.

The TestGRE should return the following when run from the command line:

C:JavaBinSearchTree>java TestGRE
Please Enter a valid FileName: StudData.dat

Choose an operation:
1: contains (string)
2: remove (string)
3: add (string)
4: print (traversal order)
9: stop Testing

Enter choice: 4
Choose a traversal order:
1: Preorder
2: Inorder
3: Postorder
3
The tree in Postorder is:
Brown in NJ earns 89 verbal, and 67 quantitative.
Arnold in VA earns 77 verbal, and 88 quantitative.
Thompson in NY earns 99 verbal, and 99 quantitative.
John in VA earns 89 verbal, and 89 quantitative.
Conner in NY earns 98 verbal, and 100 quantitative.
Smith in MD earns 89 verbal, and 89 quantitative.

Choose an operation:
1: contains (string)
2: remove (string)
3: add (string)
4: print (traversal order)
9: stop Testing

Enter choice: 2
Enter Student's Name to remove: Arnold
Verbal Score: 77
Quantitative Score: 88
State: VA
remove(Arnold, 77, 88, VA) returns true

Choose an operation:
1: contains (string)
2: remove (string)
3: add (string)
4: print (traversal order)
9: stop Testing

Enter choice: 4
Choose a traversal order:
1: Preorder
2: Inorder
3: Postorder
3
The tree in Postorder is:
Brown in NJ earns 89 verbal, and 67 quantitative.
Thompson in NY earns 99 verbal, and 99 quantitative.
John in VA earns 89 verbal, and 89 quantitative.
Conner in NY earns 98 verbal, and 100 quantitative.
Smith in MD earns 89 verbal, and 89 quantitative.

Choose an operation:
1: contains (string)
2: remove (string)
3: add (string)
4: print (traversal order)
9: stop Testing

Enter choice: 3
Enter Student's Name to add: Arnold
Verbal Score: 77
Quantitative Score: 78
State: CT

Choose an operation:
1: contains (string)
2: remove (string)
3: add (string)
4: print (traversal order)
9: stop Testing

Enter choice: 4
Choose a traversal order:
1: Preorder
2: Inorder
3: Postorder
2
The tree in Inorder is:
Arnold in CT earns 77 verbal, and 78 quantitative.
Brown in NJ earns 89 verbal, and 67 quantitative.
John in VA earns 89 verbal, and 89 quantitative.
Thompson in NY earns 99 verbal, and 99 quantitative.
Smith in MD earns 89 verbal, and 89 quantitative.
Conner in NY earns 98 verbal, and 100 quantitative.

Choose an operation:
1: contains (string)
2: remove (string)
3: add (string)
4: print (traversal order)
9: stop Testing

Enter choice: 9

C:JavaBinSearchTree>

Now I just need the following missing code to test this system, and to make this all work:

import java.util.*;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.File;
import java.io.IOException;

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

....

}

Attachments

Solution Summary

The expert examines Java binary search tree solutions.

$2.19