Calculator

0
AC +/- % /
7 8 9 x
4 5 6 -
1 2 3 +
0 . =

How it works

This calculator is built as a finite state machine with no if statements. Each state is an object that defines what every button does. Pressing a button calls the handler for that button in the current state, which updates the display and transitions to the next state.

States

Current state handlers