Confusion about programming Logic

I think this is right what I want, I will try it. Thank you!