So far our programs have been Input something either using a textbox or a inputbox.
Process - performing some sort of mathematical calculation
Output to the user in the form of a Message box.
These programs have limited functionality, what is a user wants to have options such as different answers to a question. Now we introduce SELECTION
In preparation for this, read and watch the following video. Click here
Can I make a decision in my program by using an IF statement?
Selection is a really important part of programming, without it the user would have limited functionality. You would want the user to have choices depending on what they select. Think of a screen in Mcdonalds where you have to select your food choice, if you select chicken nuggets the price for these appear. If you select a Meal Deal it will ask you for you main meal choice, chips or a healthy version and then what drink. Within this program sits lots of IF statement so the user can have a choice of what they want to buy, When designing programs with IF statement within them we use FLOWCHARTS to map out the path and options. With Mcdonalds you have lots of choice so there are lots of IF statements.
Example of a FlowChart for gaming.
It could be the user types in number 1 and this is red, number 2 green etc. You would need to store the number value as a variable and then use IF to deicde if 1 then show colour Red etc.
Another option would be option buttons i.e. if a user selects an option button then the colour would change (Use this link to help)
Write an application for a cinema that allows the user to enter a person’s age. The user should be notified whether the person should pay child, adult or pensioner price for a cinema ticket.
Child if age <= 16 pays £3.50
Adult if age > 16 and <= 65 pays £5.50
Pensioner if age > 65 pays £2.50