if you look
here. On the diagram you see a simple potential divider.
Vin would be your 24V
suitable values for the resistors Z1 and Z2 would be 18K and 4.7K respectively
Vout would then be connected to a Mach input and would be at 5V
You'd put your switches in parallel between the 24V source and Z1
With all switches open, the 4.7K resistor would pull the input down to 0V
With any switch closed the input would be at 5V