Welcome to Apple Support Communities
If you purchased the iMac less than 3 years ago and it has got one of the defective hard disks, Apple will still replace it for free. Make a backup of your files with Time Machine and take your computer to an Apple Store or reseller. A Genius will check if your Mac was purchased less than 3 years ago.
If the computer is older, you will have to pay. Note that if you already have the iMac on April 12th, 2013 and before, and you knew that your iMac had a defective hard disk, you should have taken it even if the hard drive was working correctly