Re: If voting systems are hacked and the count altered, what does a democracy do?
Those considerations are exactly why we ought to revert to systems that are transparent or can be made so after the fact, for which the most efficient solution almost surely is hand marked paper ballots, counted by machine, maybe, for quick results, audited by hand on a sample basis and, if discrepancies are found, recounted in full by multiparty teams.
There still will be issues - hanging chads are a bad memory from the 2000 election, and various techniques are known and were used somewhat commonly for a century or more before voting machines came into use. Ultimately, the questions that come up are decidable, however, and the real constraint is legal requirements for certification of results, for instance before the required date for electoral college action on a president and vice president, or date of inauguration or legislative organization. The latter are not always fixed: Al Franken, for example, was not determined to be the Senator-elect from Minnesota until June 30, 2009, nearly six months after organization of the 111th Congress to which he was elected.
As far as I can tell, the primary beneficiaries of voting machine use are the manufacturers and the TV news media, who can report many or most results on the 10 or 11 PM news election night.