expressions with conditionals

attempted to come up with a formula