Instructions
Remove the original brake cable from the bicycle by unscrewing the nut holding the cable to the derailleur (for whichever brake cable you're replacing) and the accompanying washer. Unscrew the other side of the cable from the brake handle on the handlebar. The one mounted to your left handlebar always controls your front brake, and the one on your right handlebar always controls the rear.
Go to the bicycle shop and have them cut you a new brake cable. It's important to have a bike shop cut this for you because of how different bicycles and different braking systems work. You don't want to make a mistake and get hurt from a badly cut cable. If your housing's ends are undamaged, you can probably use them again, but consider buying new ones so everything works like a new braking mechanism should.
Install the new end caps on the new brake cable. The caps pop on, and the wire goes through the hole in the middle. Be careful with the cable so it doesn't fray. Mimic the route from the old brake cable with the new one between the handles and derailleur mechanisms. Tighten the nuts to hold them in place. Slowly roll the bike and test the brakes to make sure they work properly.