From the course: Building Your First iOS 17 App

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Calculating the tip total

Calculating the tip total

- [Instructor] Now it's time to calculate the tip amount and put it in the text view if indeed we have a numeric value to work with. So find the if statement that we created in a previous movie. And then in the text area, let's change that placeholder text to be tip amount. And then we'll put a colon and then our currency symbol. Mine is a dollar sign. And then remember, if we want to put any variables inside of a string, we use that backslash and parentheses operator. And let's just start by putting total num in here. Notice that I'm not using total. Total still a string, but total num is a double value or a decimal value. And we're going to put that right there. Now watch what happens when I put an amount in there. So I put a number in there and then I'm seeing the double version of that number. It would be better if it was formatted to our appropriate currency, but for now, this will suffice. To calculate a tip…

Contents