Hello and welcome to this annual lesson in which we are going to take another example.
This is a salary calculation example and this program we want to calculate the salary of workers as
follows.
If the working hours was greater than 40 hours per week each hour will be two dollars and any additional
hour will be calculated with three dollars.
So if you worked for 35 hours per week it will be counted and multiplied by two dollars.
So you will take seventy dollars in total.
But if you work for more than 40 hours let's say 70 hours the first 40 hours will be multiplied by two
dollars while the remaining hours will shift.
In this case our fair city will be multiplied with three dollars because they are treated like overtime.
In your work so to make it more clear you are going to do this in flowchart and I'm going to explain
the sequence in a step by step manner.
But let's first write the equation here and this PowerPoint.
Now if he did work for 40 hours he will take two dollars an hour about 40 will be counted as a three
dollar hour and this can be done using a simple formula.
Now let's start by creating a new blank diagram.
Go to the flow chart area and start adding elements depending on your needs.
As you can see here we have these two items for the start.
You can either use this rectangle or round rectangle or use these two.
We will use this one
and we will use another one for the end now.
After losing this this double clicked on name ID start
now.
The logic to solve this problem can be as follows.
First find the number of hours.
So we will take an input which is the number of hours
read.
The first item that I can write inside it.
Use this one nested read pause.
Now that we did three hours.
The second step is to check if the number of hours is greater than 40.
Now that this item and ask hours above 40.
Now if yes we are going to apply an equation if no we are going to apply a different equation.
Now if the answer were was yes and here then Sara was No.
Now if yes
salary will equal
40 multiplied by two.
Now I'm going to explain why did we use this now plus
ours minus 40.
Let's add another parentheses
and that's also multiplied by three.
I'm going to increase this now if no then hours salary equals hours multiplied by two.
Now if the number of hours is above 40 This means that we have 40 hours multiplied by two.
Now how to calculate the remaining hours.
Let's say that we have 70 hour 70 minus 40 will be 30 hours.
So the 50 hours would be multiplied by three and the total number would be the salary.
But if no.
This means that we have hours less than 40 and we are going to multiply these by two and this is it.
This is how you can calculate the salary.
In both cases we are going to do.
We are going to print the salary and then we are going to stop.
So in order to print let's use this shape print salary then and
for both of these
K but small this year.
Let's hold this here.
Let's write a text.
If yes
if no.
Now let's do this again.
Who will solve the problem.
We will leave the number of hours after that.
We are going to check of the hour's about 40.
We are going to calculate using this equation.
If they are below 40 you are going to multiply by two to calculate the salary.
Then we are going to print the salary and stop the program.
That's it.
This is how you can calculate the salary for employees using flow charting.
That is a step here.
You can add it depending on whether you want to add it or not.
We cut all this line and we can add a rectangle rectangular shape to define.
I was
on salary.
This is variables
out as equals zero salary equals zero.
This can be used to add different variables to your program.
You can add it or not depending on whether it's something you do usually or not.
But anyway if you write your code you are going to need these variables.
So I prefer adding it before starting my flowchart to make sure that I have all the variables I need
defined before start coding.
Now let's check this one again.
If we have 70 hours 40 points applied by two will be 80 plus 70 minus 40 will be 30 multiplied by three
three two by three will be 90 90 plus 80 will be a total of 400 and 70 dollars.
If we are calculating this doughnut and this is how you can calculate a salary for sure you can color
these depending again on your needs but that's it for this lesson if you have any questions please ask
him that you aren't able I hope that now you are starting to understand flow charting the basic delivery
for thinking on how to create your own flow chart if you have any question again ask him back you on
the board thanks for sharing this is coding Academy.