The trick with programming is thinking things through. The rules are actually very broad -- that is, there is (almost always) no "one true way" to do things. The toughest part is dealing with syntax -- how things are written.
If you were told to describe how to make a PBJ, you might give a very simple explanation. Person trying to make one will come back and say "it's not working".
What exactly is not working?
A lot of your code is trying to do things out of order. It is like coloring, for example, a rainbow. Red on top, then orange, then yellow, the green, then blue, then magenta.
You've got most of the colors on the page, but they aren't in order.
For example, you ask the user for a year and get one with
cin >> b;
.
Then you tell the user what year he entered.
Then you check to see if the user entered a valid year, and if he hasn't ask him to try again.
Those steps are in the wrong order.
If you haven't already, I really recommend you use some functions to do the repetitive stuff. Getting a student's grade and year are a good thing to put in a function, since you will want to do it over and over and over again.
Also, you should use more descriptive variable names than "a" and "b". For example, a great name for a variable holding a year would be
year. Makes sense, right?
Take a look through the tutorials on this site, and try to fix your program some. If you are still lost, post back with your current code and we'll see how we can help you best.
http://www.cplusplus.com/doc/tutorial/
Take heart. Learning this stuff is not easy. It just takes time and a lot of patience.