Zener Diode not working as expected
You need a resistor between the switch and zener, and a resistor between the Vout point and ground, like so:







simulate this circuit &ndash; Schematic created using CircuitLab

With the switch up, the Zener will limit Vout to 4 volts.

With the switch down, the Zener will not conduct, and Vout will be 3 volts (less a bit, due to the current drawn by R2)

Without R1, when the switch is up, infinite current would flow through the Zener diode as V1 tries to deliver 5 volts, and D1 tries to hold the voltage to 4 volts.