A house that's built well and is given the proper care can last hundreds of years. But -- where's that dripping coming from? It could be your roof telling you it needs to be replaced, even if it's just a decade or so old.

If you have a 30-year mortgage and aren't likely to move during your loan term, you're likely to need a new roof at least once.

A roof isn't cheap. Let's take a look at what it's going to cost you.

Factors determining the price

Workers were moving a lot of brown roof shingles to the roof to make a step towards the roof.
NarisaFotoSS / Shutterstock
The type of roofing materials are a big driver of the final cost.

The cost of replacing a roof has many variables. A few things to consider are: the roof's size and slope; its materials; any water damage; whether there are chimneys or skylights; and removal of the old roof.

The size of the roof will obviously impact cost, because more material will be needed to cover the space. Chimneys and skylights increase the price because of the special work and materials needed to install around them.

As for the slope, the steeper the roof, the higher the costs. That's because it becomes more dangerous for roofers to do their job, and they may require safety equipment.

Removing an existing roof can cost up to $5 per square foot and can total $1,100 or more for a basic ranch-type house, according to HomeAdvisor.com. If roofers uncover serious water damage or rot, removal can be much more expensive.

So what should you expect to pay?

Custom built luxury house with nicely trimmed and landscaped front yard, lawn in a residential neighborhood. Vancouver Canada.
romakoma / Shutterstock
Expect to pay several thousand dollars for your new roof.

The national average total cost of removing and replacing a roof is about $7,300, says HomeAdvisor.

But while the high end of the typical price range is about $10,000, a new roof made of top-of-the-line materials can cost as much as $30,000 or even $100,000.

Asphalt can run between $120 and $400 for every 100 square feet of roof. Metal costs up to $1,800. But the price of slate or tile can be as much as $4,000 per 100 square feet.

Need to save for a new roof? Use our calculator and find out how much you need to save each month to reach your goal.

When is it time to replace?

Repairing of roof by cutting felt or bitumen shingles during waterproofing works.
Spok83 / Shutterstock
If your roof leaks, it obviously needs replacing.

A roof can be replaced for several reasons, maybe for a simple aesthetic upgrade or if you want to try making your home more energy efficient.

But often it will be very obvious that it's time for a new roof — like if your current roof leaks every time it rains.

Variables such as sun and rain exposure, the age of the existing roof when you purchased the house, and the energy efficiency of the roof can force you to replace your roof sooner, rather than later.

A flat roof will have a short lifespan: likely just 10 years. That's because water, leaves and other debris tend to accumulate on a flat roof and cause damage. Other styles of roof may last 30 to 50 years.

As for the roofing materials, asphalt shingles may last 30 or more years, while a metal, tile, or slate roof may endure for 50 years or more, says Angie's List. Note that more durable materials carry a higher price tag.

Follow us on Twitter: @moneywisecom