Loading...
Hello, my name is Mrs. Holbrook and welcome to Computing.
I'm so pleased you've decided to join me for the lesson today.
In this lesson, we are going to be designing a solution for a programming project that requires the use of subprograms. Welcome to today's lesson from the unit programming subprograms. This lesson is called Programming Project Subprograms one, and by the end of today's lesson, you'll be able to use a project brief to design a solution.
Shall we make a start? We will be exploring these key words in today's lesson.
Structure chart.
Structure chart, a top down diagram used to design the structure of the subprograms required for completing a programme.
Flowchart.
Flowchart, a visual representation of an algorithm or programme.
Look out for these key words throughout today's lesson.
Today's lesson is split into two parts.
We'll start by investigating a project brief and then we'll move on to represent a system using a flowchart.
Let's make a start by investigating a project brief.
Copington Adventure Theme Park has just purchased an automated ticketing system and would like you to programme the interface for customers to use.
The ticketing system should ask the customer various questions about their visit requirements before it provides a total charge, asks for payment, and issues a ticket.
Ticket prices for Copington Adventure Theme Park are 20 pounds for an adult, 12 pounds for a child, and 11 pounds for a senior citizen.
Visitors also have the option to buy a wristband for 20 pounds, which gives them priority access to rides.
Parking is free, but a car pass must be displayed.
The project brief specifies the programme should do the following: Provide a welcome message.
Display the entrance ticket prices.
Ask how many adult tickets are required.
Ask how many children tickets are required, and ask how many senior citizen tickets are required.
Ask how many wristbands are required, ask for the lead booker's surname for the ticket, and then ask if they require a pass for the car park.
The programme should then display the total cost, ask for payment.
The machine only accepts 10 pound and 20 pound notes.
Each note entered will need to be counted.
Display change if there is any.
Print a ticket displaying the lead booker's surname, the tickets purchased, wristbands purchased, and today's date.
Print a car parking pass if it was required.
Use data validation techniques to avoid runtime errors through incorrect data entry.
And lastly, thank the customer for their purchase.
This is what a sample output from the programme may look like.
So you can see we have the welcome message at the top, and then we are displaying the entrance ticket prices to the user.
We ask the user how many of each type of ticket they require, so adult, child and senior citizen, and the user can enter the amount that they need.
This is a follow on from the programme, so we then ask how many wristbands do they require and what is the lead booker's surname? We then ask whether they require a parking pass for the carpark and we display the total cost of the ticket.
We then ask them to enter their notes and the total amount that's paid and we calculate the change.
For the last part of the programme, we are displaying or printing out the ticket and the parking pass, finishing with a thank you message to the visitor for their purchase.
Time to check your understanding.
Which of the following is not a requirement of the theme park booking system? Is it A, how many adult tickets are required, B, print a car parking pass, or C, calculate the discount for annual members.
Pause the video whilst you have a think.
Did you select C? Well done, you remembered the requirements of the system well.
The theme park ticket booking system does not calculate any discount for annual members.
Using a structured approach means breaking down a problem into smaller subprograms. A structure chart is created to decide on the hierarchy of the programme.
The programme has multiple requirements and will need to be broken down into smaller subprograms. So you can see at the top level we have the ticket booking system.
We then have the first subprogram, which is going to be display ticket prices.
The identifier for this subprogram is going to be display underscore prices.
It's not going to need any parameters and it's not going to return any values.
Can you think about what other subprograms may be needed for this system? If a subprogram needs to pass a value back to the main programme, what should it use? Is it A, a return value, B a parameter, or C, a variable? Pause the video whilst you have a think.
That's right.
If a subprogram needs to pass a value back to the main programme, then you should be using a return value.
Okay, we are now moving on to our first set of tasks for today's lesson, and you're doing a fantastic job so far, so well done.
I'd like you to plan out the remaining subprograms for the ticket booking system.
Remember, the first one has been done for you, which is display ticket prices.
Note, you may need to add more subprograms to your structure chart then are shown on this diagram.
Pause the video whilst you have a go at the task.
Once you've decided on what the subprograms are going to be, add the details for the interface for each subprogram.
So remember, the interface is made up of the identifier, the parameters, and the return value for each subprogram.
Again, remember, you may need to add more subprograms to your structure chart than is shown on this diagram.
Pause the video whilst you complete the task.
How did you get on? Did you manage to create some subprograms for the theme park booking system? Great work.
Let's have a look at a sample answer together.
So we had the ticket booking system at the top and we also had the first subprogram planned, which was display ticket prices.
We've then added some more subprograms, so we have calculate entrance price, car parking, collect payment, and issue ticket.
Remember, this is just a sample solution.
You may have divided the problem into different subprograms, which is absolutely fine.
You were then asked to plan the interface for each subprogram.
Again, let's have a look at this sample answer together.
But remember, you may have divided the problem differently.
So the first one, display ticket prices, had already been done.
So let's have a look at the next one, which is calculate entrance price.
The identifier for this is going to be calculate underscore entrance.
It's going to take in a lot of parameters.
So we're going to have booking name, adult total, so the total number of adult tickets, child total, senior total and wristband total.
It's then going to do some calculations and return the total cost to the main programme.
For the car parking subprogram, the identifier is going to be parking.
It's going to have no parameters, but it is going to return the value parking required to the main programme.
For the collect payment subprogram, the identifier is going to be collect underscore payment.
This subprogram has one parameter, which is total cost, but it doesn't return any values.
And then the last subprogram is going to issue the ticket.
So this identifier is going to be issue underscore ticket and again, it has lots of parameters.
So booking name, adult total, child total, senior total, wristband total, total cost, and parking required.
It doesn't need to return any values to the main programme, though.
If you want to go back and revisit your subprograms, remember, you can pause the video now before you move on to the next part of the lesson.
Okay, we are moving on to the second stage of today's lesson and you're doing a fantastic job so far, so well done.
We are now going to represent a system using a flowchart.
A flowchart is a diagram used to illustrate the steps of an algorithm.
Flowcharts are made up of symbols, each containing a single step of an algorithm.
The shape of the symbol represents the type of process that the symbol contains.
Arrows are used to show the flow of execution.
When investigating the requirements of a system, it's useful to plan the programme flow using a flowchart.
Here are some flowchart symbols.
So the lozenge shape is the terminal.
An arrow represents the flow line.
The rectangle is used to represent a process, so maybe a calculation.
The diamond is used for a decision.
The parallelogram is used for input and output, so displaying a print message to the user or taking input in from the user.
And lastly, the rectangle with the two lines is a subprogram.
Time to check your understanding.
Which flowchart symbol is used to represent a decision.
Is it A, B, or C? Pause the video whilst you have a think.
That's right, the diamond is used to represent a decision in a flowchart.
Sam here has created a flow hart for the first part of the theme park booking system.
So we have start, print, welcome to Copington Adventure Theme Park, and then display underscore prices.
Time to check your understanding.
What is display underscore prices in Sam's flowchart? Maybe pause the video whilst you have a think.
That's right.
The rectangle with the lines is a subprogram.
So display underscore prices is a subprogram in Sam's flowchart.
The display underscore prices subprogram can be represented in its own flowchart.
We have display underscore prices and we have the outputs that are going to be printed.
So we're going to print the title entrance prices, and then we're going to print the price of each type of ticket.
Okay, we are moving on to our second set of tasks for today's lesson.
And you're doing a fantastic job so far, so well done.
I'd like you to create a flowchart to represent the whole theme park ticket booking system using the project brief to help you.
Remember, you've already split the project into subprograms in task A, so you can create smaller flowcharts to represent each subprogram.
That'll be easier to solve.
Remember, if you need to at this point, you can go back to the previous slides where you can find the project brief and the example subprograms from task A to help you.
Pause the video whilst you complete the activities.
How did you get on? Did you manage to create your flowchart for the theme park ticket booking system? Great work.
Let's have a look at a couple of sample answers together.
So here is a small section of the programme which is represented in a flowchart.
This represents the main programme, which will call upon the subprograms, which will make up the main programme.
So we have start, we have the print message which says, Welcome to Copington Adventure Theme Park.
And then we call numerous different subprograms. So display underscore prices, calculate underscore entrance, collect underscore payment, and issue underscore ticket.
Even though these are calling different subprograms, the order these are displayed in is important 'cause we can't issue the ticket, for example, before we've displayed the prices to the user.
Let's have a look at one of the subprograms in a bit more detail.
So this is the subprogram for calculate underscore entrance.
This subprogram contains a number of processes which, remember, are represented in our rectangle.
So we have calculate underscore entrance at the top.
We then calculate the adult total.
So adult underscore total is equal to adult underscore tickets multiplied by 20, 'cause adult tickets are 20 pounds each.
We then do a similar calculation for the child and senior tickets.
We then do a calculation for the wristband total, and then we calculate the total underscore cost by adding all of those together.
So adult underscore total plus child underscore total, plus senior underscore total plus wristband underscore total.
Remember, this is just a sample solution for the flowchart.
Your system may have been divided into different sections and you may have solved the problem in a different way.
That's absolutely fine.
Okay, we've come to the end of today's lesson and you've done a fantastic job.
Let's summarise what we've learned together.
A project brief specifies what the requirements of a programme are.
A structure chart is a diagram used to design the structure of the subprograms required for completing a programme.
A flowchart is a visual representation of a programme.
I hope you've enjoyed today's lesson, and I hope you'll join me again soon.
Bye!.