Time
4 hours 19 minutes
Difficulty
Beginner
CEU/CPE
4

Video Transcription

00:00
Hi and welcome back to the course. I hope you guys are doing well. And if you remember in the last video we wrapped up module to and in this video lecture we're gonna be starting module three, which is all about control. Flow and structures
00:16
Now is always I've listed out some learning objectives for you so that you're clear going into the video lecture on what you should be expecting to learn out of this lesson.
00:27
So first off, we're going to be understanding What if statements are?
00:33
I also understand why or when we would ever have to use them. Why do they even exist in the first place?
00:40
As well as understand this syntax of if statements. If you have forgotten what syntax means, it essentially refers to the grammar or the rules in which you can write a certain thing. In this case, we're talking about if statements
00:58
All right, So what is controlled flow?
01:02
Now if you just piece apart the word itself, control and flow isn't that complicated to understand when we talk about its general context. But when it comes to programming, control, flow is essentially how your program makes decisions and not only decisions but decisions about certain parts,
01:22
and the regular order in which code is executed is basically from top to bottom. So any program that you write code executes from top to bottom. But as soon as you add in some control structures such as four loops If statements a break, statements continue statements, return statements,
01:42
all of these
01:44
separate control structures or statements altered that control flow. Now, instead of going from top to bottom, your program goes down different pathways.
01:56
All right, so here is a diagram of me demonstrating what control full is. So you essentially have a condition. And once you start, you check. If that condition is true, if it happens to be true than a certain statement is executed, and if it is false,
02:12
then something else is executed. And this is a very basic,
02:15
high level example of what control flow is
02:22
all right. Perfect. So not moving onto if statements, what are if statements to begin with
02:29
and if statement is a programming conditional that have proved true, performs a function or displays information,
02:36
and here is an example of an actual if statement now we carefully analyze this program or look at it, we can see that it is asking a user to enter a number, and it is doing that through a scandal scanner. Sorry, and that is through the Java that utility scanner
02:53
package that we have imported.
02:57
Then once the user enters a number, that number is stored into the user number variable
03:02
Moving on. This is a mean part that is related to today's lecture. We check if the user's number equals five using an if statement,
03:14
and if it does equal to five, then we simply print out to the consul. You entered the right number.
03:21
Otherwise, that is what this else if is doing so each if statement can come within else. If and you can write that it is an an optional thing, but you do not have to do that. So I'm saying, if the number is five, then print out you entered the right number. Otherwise,
03:39
if it is not five,
03:40
then print out. Sorry you entered the wrong number. So this is a very basic example of how an if statement work
03:50
some other examples of if statements could be, Let's say we're trying to calculate some sort of cost to any event. Or let's say we're trying to calculate if someone qualifies to register for a class or something like that. We have to check if a certain condition isn't met
04:09
and it just gives it away, right in the word where we say, if
04:13
that if is what will be what we're going to be using in our programs, which will help us make decisions all along the way.
04:24
All right. So I hope you understood if statements and what we went over in this video lecture and just to summarize everything we discussed. What if statements are
04:33
as well as I went to use if statements, which, as I mentioned, is when you need to make certain decisions
04:40
as well as why we would need them?
04:42
And then we discussed how we can actually write them. It's a simple as writing if and then else if if you have a need of going a different path in your program,
04:56
all right, Perfect. So now in the next video or in the next of the electorate, we're gonna be doing a lab, and in that lab we're gonna be making a fare ticket calculator, which will calculate um, an individual's ticket based on their age.
05:14
So thank you very much for watching. And as always, if you have any questions at all, please do. Let me know when you can contact me through lengthen. And I'd be more than happy to answer any questions. I look forward to seeing you next video and have a good day.

Up Next

Introduction to Java

In this course, you will learn Java starting with the fundamental and key concepts that have made it become so powerful and widely used around the world for personal and industry projects. Some concepts covered in this course are the following: Inheritance, Encapsulation, Polymorphism, and Abstraction.

Instructed By

Instructor Profile Image
Salman Haider
Cyber Security Assessnent Analyst at Bank of Canada
Instructor