It's no secret that Americans on a whole are mostly unprepared for retirement -- but sadly, that includes those who are pretty close to reaching that stage. A recent survey by Comet found that more than 40% of baby boomers have no money in a retirement plan like an IRA or 401(k). Now that doesn't mean these same folks have absolutely no assets to tap. Many own homes, for instance, that can serve as a source of equity later in life. But the fact of the matter remains: A good 50% of near-retirees are way behind from a savings standpoint. And if you're one of them, it's time to ramp up immediately.

The good news, however, is that believe it or not, you can actually still end up retiring a millionaire, even if you have no money set aside at all by the time you turn 50. You just need to commit to working longer, maxing out your retirement plan, and investing your savings wisely.

A senior couple with serious expressions look across a desk at a man in an office setting.

IMAGE SOURCE: GETTY IMAGES.

How to salvage your retirement

Let's be clear: Without independent savings, there's a good chance you'll struggle financially as a senior. That's because the income you receive from Social Security won't be enough to cover your bills. In fact, it won't even come close. In a good-case scenario, it might pay for about half of your expenses, leaving you on the hook for the rest. And that's where your savings come in.

So how do you go from $0 in savings to a sizable nest egg? You'll need to do three things. The first is commit to working longer, which, incidentally, isn't just good for your savings, but potentially good for your health. If your original plan was to retire in your mid-60s, aim to keep plugging away until 70 or later. This will accomplish a couple of goals -- giving you extra years to sock away money, and helping you grow your Social Security benefits so you get the maximum monthly payout possible.

The next thing you'll need to do is commit to maxing out your retirement plan for the remainder of your career. Now if you're dealing with an IRA, that means setting $6,500 aside per year. If you're lucky enough to have a 401(k), however, it means saving $24,500 a year. (Both of these figures assume you're age 50 or older; the annual contributions limits for both account types are lower for younger workers.) Now to free up that amount of cash, you'll need to take a hard look at your budget and start cutting expenses. But if you make that sacrifice now, you'll reap the benefits in retirement.

Finally, you'll need to invest the money in your IRA or 401(k) to maximize its growth. And in that regard, the stock market is really your best bet. Now it's true that as we get older, we're supposed to shift away from stocks and into safer investments, like bonds. But if you're somewhere in the ballpark of 50 and are planning to work until roughly age 70, that gives you a solid 20-year investment window. And that's more than enough time to ride out the market's ups and downs, which means you should start out going heavy on stocks and work your way toward bonds only once retirement grows a lot closer.

Now if you load up on stocks, there's a good chance you'll score an average yearly 7% return on your investments, because that figure is actually several points below the market's average. So let's run some numbers and see where that leaves us, assuming you follow the above advice:

If You Start Maxing Out a 401(k) at Age:

Here's What You'll Have by Age 70 (Assumes a 7% Average Annual Return):

50

$1 million

55

$616,000

60

$338,000

65

$141,000

Data source: author.

And there you have it. If you start maxing out your 401(k) at age 50 and snag the 7% average yearly return we just talked about, you stand to retire with a solid $1 million at age 70. But as you can see in the above table, the older you get, the more your ending balance drops, in which case you might consider working until, say, 75, to make up the difference.

Also keep in mind that even if you don't have access to a 401(k), you can still aim to save $24,500 a year (or more) for retirement. You just won't get the same tax benefits.

Even if you don't manage to amass $1 million before your career closes out, retiring with some money is far better than retiring with no savings at all. So no matter your age, let this be your warning: It's on you to secure your future. And the more effort you make in that regard, the less financially fragile your retirement will be.