From the course: Programming for Non-programmers: iOS 17 and Swift 5

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Challenge: Conditionals

Challenge: Conditionals

- [Narrator] And now for this chapter's challenge, let's review what we talked about so far. Conditionals manage control flow by using if/else statements to execute certain blocks of code and a single condition can have multiple expressions. We got a little bit of practice throughout the chapter writing these kinds of statements. And now for the challenge. But first, a little bit of background. When working with a calculator and you press some numeric buttons, let's say you push a 1 and then you push the plus button. The next thing that happens is that when you press another button, that that number is going to replace the 1. So remember, you have two sets of numbers that you're performing operations on when you're creating a calculator. The 1 that was entered in before hitting the multiplication, subtraction, or addition button, and the 1 that was pressed after. In order to add that functionality, we need to check to see if the last button was pressed was a mode button. In other…

Contents