One of the military’s biggest problems of the past five years is the political shell game Washington has played with ­defense spending and the Pentagon budget.

So, as Congress is now trying to rewrite the federal tax law for the first time in more than a decade, here’s an idea: A dedicated military tax.

Lawmakers could set a military tax to a specific rate. It would be clearly labeled on everyone’s pay stub. And the money would go directly to the Defense Department.

It’s not that bizarre of an idea. Your pay stub today has a line labeled “FICA” that is a dedicated tax earmarked by law to fund the Social Security trust fund that pays retirement checks to elderly citizens. And many states have dedicated taxes earmarked for schools and other specific government operations.

Why can’t Congress write a tax code that is clear and transparent about what the military gets? One that ensures the military gets a reliable funding stream? One that would be naturally adjusted for inflation every year?

That’s not the way it works right now.

Ultimately, about a quarter of all federal tax dollars goes to the Defense Department. But that money must first be collected through a general income tax, then put into some theoretical pool of all federal tax dollars so Congress can argue about it every year.

It becomes an endless cycle of robbing Peter to pay Paul. The Defense Department gets whatever comes out of that annual, unpredictable circus.

At the crux of the disaster known as “sequestration” was lawmakers’ inability to agree on precisely how much money would go to the Defense Department and how much would go to everything else.

Lawmakers should just declare a military tax, and set it as a percentage of income. Rich people would pay more, as they always have. So, for example, instead of having millions of Americans in a 25 percent tax bracket and requiring them to pay a general purpose 25 percent tax, the tax law could instead have those same Americans pay 15 percent in general purpose, non-military taxes and 10 percent in military taxes. By law, that money would go straight to the Defense Department. No debate about it.

If Congress or the military thought the budget was insufficient, they could ask for more and seek to raise that tax. If voters didn’t like that, they could oppose it. The process of funding the military would be transparent and obvious to all.

Some people could advocate for raising military spending more than general “domestic spending.” Or vice versa.

Both are legitimate political viewpoints.

Right now, that age-old argument of “defense spending” vs. “domestic spending” is hammered out behind closed doors by the “congressional leadership.”

It’s a zero sum game. Spending money on one requires money taken from the other.

A dedicated military tax would foster a much healthier public debate. It would directly fund the military and bypass Washington’s ridiculous budget process. It would give military planners the “stability” they crave.

It would encourage more discipline on the military’s own spending by eliminating the all-too-common logic of spending money before the end of the fiscal year because it might somehow disappear.

In short, there would be far fewer games played with military spending. And the military would be better for it.

Moreover, a military tax could even open up new ways to encourage and reward military service. For example, maybe all veterans who serve a single term get a 10-year break from paying any military tax — the logic being that offering up individual service is a form of payment. Maybe retirees would get a lifelong exemption from the military tax.

Realistically, a tax break like that would amount to thousands of dollars a year.

Defense Secretary Jim Mattis told ­Congress this summer that, “No enemy in the field has done more to harm the combat readiness of our military than sequestration.” Sequestration is just another word for a total failure of the government’s budgetary process.

Many people might balk at the idea of a military tax. But it’s hard to make the case that the current system is working.