This topic hits close to home for me.
I was horrible at High School. I failed more classes than I care to admit. It was not due to a lack of intelligence (although perhaps some might disagree :) ) , but rather a complete apathy to the entire situation. I did not see the relevance of the assignments to anything that I wanted to do. I also naively considered myself to somehow be so "awesome" that I did not really even need to pay attention in school. I would focus on what I wanted to focus on and that is it.
I considered myself to be terrible at math. This was part due to the fact I did not due the homework and part due to the fact that I had "mostly" terrible teachers. My algebra teacher in High school was amazing and he is probably one of the sole reasons that I had any sort of hope when it came to mathematics. Every other teacher could not seem to be bothered to really teach the material or they were so busy getting off topic that we learned very little. What we did learn I did not understand due to not really paying attention anyway.
During this period I had been playing with programming and I had seen glimpses of where things I learned in the class room could help me in my code, however such inspiration was crushed by the sheer mind numbing boredom.
I graduated Magna Cum Laude in College with a 3.88 GPA and bachelors degrees in Computer Science, Physics, and Mathematics.
So what changed?
One night I had... I guess you could say an epiphany... I realized that while I never envisioned my "awesome" self in a low paying and manual labor type job, that is exactly where I was headed with my attitude towards both schooling and effort in general. I realized this during my junior year... It seems such an obvious revelation, but for me it made all of the difference. I made every effort to apply myself and my grades did improve... I did well on state tests and managed to get accepted to college.
I cost myself a lot of potential scholarships (although I would earn more in college from my grades) but the plus side is I knew the taste of failure and I also knew that even if I did poorly in a class that it was not the end of the world!
All this to say the case is not hopeless. Some of the things that have motivated me are the true pieces of advice:
1. There is no such thing as a free lunch.
2. Anything worth doing is hard.
3. If it were easy to do programming they would not pay you well to do it.
I suggest you discuss with him what he wants to do in life and maybe if you are lucky he will find his motivation.