For these kind of troubles you can always go check on the reference page of processing:
https://processing.org/reference/
You’ll find some example on those basic structures of the language and other functions. For example here is the page for the keyword if: https://processing.org/reference/if.html and here is one for the else keyword: https://processing.org/reference/else.html
Copy the example they gave and then try to change them to fit your needs and then come back with what you have done 