This is where we go back to selection structures that we talked about at the start. This was a decision is made and as a result of that decision there is an action.
Swift allows us to set a condition as well and an action based on it. it also allows us to set an action if something does not happen... we will get to that later
When using if-then-else statements we use operators to help us out. Here is a list of the most common ones you will use.
Operators
We will now do some practice tasks. The first one I i will walk you through making, then you will get a couple of practice ones to make sure you know how to use these.
Revenue Walkthrough
Complete the following steps for the case study
Complete an IPO
Create the Algorithm in Pseudocode
Design a suitable user interface
Create the interface you designed
Code the solution
Test your solution
You have been asked to develop an application that will calculate a companies net income, revenue less expenses. The user needs to be able to enter a value for revenue and a value for expenses. The net income should be black if it is in profit or red if making a loss.
Programming Task - My Bonus
Complete the following steps for the case study
Complete an IPO
Create the Algorithm in Pseudocode
Design a suitable user interface
Create the interface you designed
Code the solution
Test your solution
Simon is paid a 2% bonus on his annual sales. He wants a program that calculates and displays the amount of his bonus. It should look like the application above.
There has been a change in Simon’s bonus structure. Now Simon is paid a 2% bonus only when he sells at least $3,000 in product; otherwise, he is paid a 1.5% bonus. Code and test the solution.
Commentaires