A Cape Coral man who shot and killed his stepson last year has been sentenced to 40 years in prison for second-degree murder.