hereHere is what you can do
1.) check if the switch is connected to defined input pin, arduino starts form pin 0 sometimes we can misread while connecting.
2.) check if serial monitor has same baud rate as define in program.
3.) check the voltages around switch using multimeter.
4.) still not getting the attach a pull down resistor.
5.) still not getting invert the logic and current flow as suggested by @JRobert.
Check if the switch is connected to the defined input pin. The Arduino starts form pin 0 and sometimes we can misread while connecting.
Check if the serial monitor has same baud rate as defined in the program.
Check the voltages around switch using a multimeter.
Still not getting a solution? Attach a pull-down resistor.
Still not getting a solution? Invert the logic and current flow as suggested by JRobert.