Hy evry one i need your help for a class room project

In my last project I did something like this.

Ugh. Nasty, blocking code. Why do you say that the states in your code needed to be loops ? What do you think the loop() function is for ?