This homework assignment will give you additional experience with writing basic Java programs and then some initial experience with inheritance and types.

- Rewrite the Salary.java question from homework assignment 1 with the following
modifications:
- Create an instance variable in the Salary class in which you place the computed value for the average salary once all the salaries have been read (as opposed to a local variable in the Salary constructor).
- Create a method in Person for printing the person's information and true if the person's salary is above the group average and false otherwise. Your method will need to access the parent class's average salary instance variable. Your program should call this method when printing out employee's information at the end of your program. This part of the problem is supposed to show you that instances of nested classes can access instance variables in their parent object.
- The input will be read from standard input. There will be one
person record per line. Hence the sample input from hw1 will now
look like:
nels 105000.80 mary 20000.50 frank 18153.33 nancy 91868.73 michelle 20858

Use a Scanner object, not a Console object, to read input because the TAs may redirect stdin in order to test your program. You may assume that the input is error free. - You should output the names in the order that they appear in the
input. Hence your output for the above sample input should be:
average salary = 51,176.27 nels 105,000.80 true mary 20,000.50 false frank 18,153.33 false nancy 91,868.73 true michelle 20,858.00 false

- You can either use your list code from question 7 to handle the variable-length input or you can use an ArrayList to handle the variable length-input.

**You must use my program design**. I understand it might not be either the way you would like to organize your program or even the best way to design the program. However, I want to give you experience with using nested classes and with calling methods. - The following problem will give you experience with Java's
collection classes, Java's file I/O classes, and Java's Scanner class.
Pet Detective is a game published by Lumosity that asks you to deliver pets to their homes within a specified number of moves. A screen shot of Pet Detective is shown below and you can view a video of a person playing the game here. Please note that you can skip over a pet without picking it up or skip over a home without visiting it.

As you can see from the video, at each turn you move the car to either a pet, thus picking it up, or to a pet home, thus dropping it off. As you can also observe, the car has a capacity of 4 pets. Hence once you've loaded 4 pets into the car, you must deliver a pet to its home at the next turn before you can pick up another pet.

This problem can be difficult to solve at the upper levels and one might want to write a program to try to find a solution to the puzzle (especially since Lumosity occasionally uses a puzzle that can't be solved in the required number of moves).

**Solving Strategy**. These puzzles can be expressed as an optimization problem. The puzzle solution is a Hamiltonian Circuit and hence the problem is NP-complete. Duane Mattern has managed to express this problem as an integer programming problem. However, a more efficient way to solve this problem is as a graph problem since you can take advantage of knowing the distances between nodes.**You must solve this problem as a graph problem using the following formulation**. You should represent the car, each pet, and each pet home as a vertex. You will then need to use a brute force, recursive search algorithm to find a solution and this search might take several minutes.You are free to investigate any search algorithm you want, but my solution involved always moving the car to the nearest unsearched vertex, subject to the constraint that if the car was full, the nearest vertex had to be a pet home, and then recursively continuing the search from that vertex. I would backtrack if the search failed to find a solution.

**Floyd Warshall Algorithm**. You will need to use the Floyd Warshall algorithm presented in class to compute the shortest path between each pair of vertices before you start your exhaustive search.**Input**. The input will be a file whose name is given as a command line argument. The first line of your input will be the number of moves you can use to deliver your pets. The remaining lines of input will consist of vertex pairs and the distance between the pairs. For the above screen shot, the input might begin:29 car marmot 1 car armadillo 1 fox_home cat_home 1 fox_home yellow_dog 1 cat_home marmot_home 1 cat_home yellow_dog_home 2 ...

I make the following guarantees about the input:- The home for a pet will have the name of the pet with a _home extension. For example, the name of the fox's home is fox_home.
- The input for the car will always be the first lines of input for the graph. After that there is no guarantee on the order in which the input is presented.
- Although Lumosity caps the number of pets, I don't so you don't know the number of pets in advance and you don't know the maximum number of pets I'm going to give you.

**Output**If the problem has a solution, then print out the vertices in the order in which they get visited. For example, if the car in the above screenshot makes it first moves to the armadillo, then the cardinal, then the cat, and then the armadillo home, then your output would start as:

armadillo cardinal cat armadillo_home ...

If the puzzle cannot be solved in the given amount of moves, then print "No solution found".

**Data Structure Requirements**: This is a homework assignment using Java's collection classes, so you must use the following data structures:- A map to keep track of the names of your vertices. You should be able to figure out whether it is more efficient to use a hash map or a tree map. You will need to keep some information in the value field as well. I assigned an integer id to each vertex which I then used as its index into the adjacency matrix.
- A stack to keep track of the vertices in your solution. Your search will end at the last vertex, which is the last vertex you will print out. In other words, you won't be able to print that vertex right away, but will have to wait. The best way to hold these vertices is on a stack, because you can push each vertex onto the stack as you back out of your search. When you reach the top-level of your search, the stack contains the vertices in the correct order from first visited vertex to last visited vertex.

You will probably need to use an array or ArrayList to handle your adjacency matrix. Since you don't know in advance either the number of pets or the maximum number of pets, it's probably easier to use an ArrayList. You should feel free to use other Java data structures as necessary.

**Parting Notes**- The TA should be able to execute your program by typing
java -jar petdet.jar puzzleFile

- The TA will pipe your solution into a program that checks your solution so limit your output to the vertices in your solution.
- Your search is not limited to immediately adjacent vertices. For example, in the above screenshot, you would probably start your search by moving your car to the marmot or armadillo, but if neither of those searches worked, you would next try either the cardinal or the turle, which are two "units" away.
- You can use /home/bvz/cs365/hw/hw2/petdet to find a solution
to the puzzle, but be warned that there may be more than one solution
and your solution could differ from mine.
It's usage is:
./petdet puzzleFile

- You can use /home/bvz/cs365/hw/hw2/petdet_checker to check
if your solution solves the puzzle. It's the same checker the
TA will use to grade your program.
It's usage is:
./petdet_checker puzzleFile < puzzleSolution

- /home/bvz/cs365/hw/hw2 contains the following puzzle files and screen shots of the puzzles: You can find more examples of lumosity puzzles by going to YouTube and googling for "Lumosity Pet Detective". You will find videos with various pet detective puzzles that you can then convert to puzzle files.

## What to Submit

Please submit the following two files:

- A jar file named
`salary.jar`that we can execute to test problem 1. Please include your source code in salary.jar. - A jar file named
`petdet.jar`that we can execute to test problem 2. Please include your source code in petdet.jar.