All the answers represent one of many potential correct methods for solving the problems assigned in class. Just because your program doesnt look like these programs does not mean that the program is incorrect or invalid.
Book Exercises
Non-book Exercises