Below a configuration of a Cisco 3560 configured as a layer 3 switch.
After setting this up, the 4 laptops can ping each other.
Below the partial config:
[config…]
!
ip routing
!
[config…]
!
vlan 5
name vlan-5
!
vlan 10
name vlan-10
!
vlan 20
name vlan-20
!
vlan 30
name vlan-30
!
vlan 40
name vlan-40
!
[config…]
!
interface GigabitEthernet0/1
switchport access vlan 10
!
interface GigabitEthernet0/2
switchport access vlan 20
!
interface GigabitEthernet0/3
switchport access vlan 30
!
interface GigabitEthernet0/4
switchport access vlan 40
!
[config…]
!
interface GigabitEthernet0/24
switchport access vlan 5
!
[config…]
!
interface Vlan5
ip address 172.16.0.3 255.255.255.0
!
interface Vlan10
ip address 172.16.10.1 255.255.255.0
!
interface Vlan20
ip address 172.16.20.1 255.255.255.0
!
interface Vlan30
ip address 172.16.30.1 255.255.255.0
!
interface Vlan40
ip address 172.16.40.1 255.255.255.0
!
[config…]
!
ip route 0.0.0.0 0.0.0.0 172.16.0.1
!
[config…]