That's how it is done in Belgium.
Think of it. If your choice is ether vote or risk a fine, you'd rather go and vote. If you go and vote, you'll learn at least a bit about the choices you have to make in the ballot.
P.S. While Belgium got mandatory voting right, it completely messed up electronic voting. I remember being an assessor in a polling station with electronic voting.
People voted, then the head of the voting station took 3 1⁄2-inch floppy disks out of the machine, put them in an envelope and drove away to the district polling committee. There was not counting, no protocol to sign. Nothing. I was appalled.