 Welcome back, in the previous segment we discussed two forms of the F statement and now we are going to discuss the most general form of the F statement. So this is as follows, it begins with if condition consequent but now we are going to have many conditions and consequents. So we will just write condition 1 consequent 1, else if condition 2 consequent 2 and you can have several such else if condition 3 consequent 3, condition 4 consequent 4 and so on. And finally the last statement, the last condition will be if condition n consequent n and followed by that you can have else alternate and this else alternate is optional. So how does this work? Well we are going to evaluate conditions in order. So condition 1, condition 2, condition 3 and so on. If some condition turns out to be true then we execute the corresponding consequent but once a condition is found to be true we do not evaluate subsequent conditions. So we deem the execution of this statement to be over at that point and we go on to the next statement in the program. If all conditions are false, so condition 1 through condition n all of them turn out to be false then we execute the alternate if it is specified. If it is not specified then we just declare that the execution of this if statement is over this entire, this entire statement say from here to here gets over if the condition if these conditions are all false and the alternate is not specified. And as always consequents and the alternate can be blocks or single statements. So I want to describe the if statement suppose it has three conditions then what would it look like if we drew a flowchart for it. So let us see, so over here we have the flowchart of the previous statement. So control executes the previous statement and now enters this is now trying to execute of a if statement. So our if statement has three conditions so it executes the first condition, condition 1 is executed. If it is true then what happens? Well in that case consequent 1 is executed not only is consequent 1 executed but we know that after that none of the other conditions are executed or their consequence are executed. We directly go on to the next statement of our program declaring that this if statement execution is over. So that is what this branch is saying. If this condition 1 that we executed turned out to be false then we execute then we execute condition 2. If this condition 2 is true then we take this branch and execute consequent 2 and then we go to the next statement of the program. If this condition 2 is false we execute condition 3 and then if that condition 3 is true we go on this side, execute consequent 3 and then go on to the next statement. If this condition 3 is false we go on this side and if there is an alternate specified it will appear over here otherwise this branch will directly go on to this point. So that is how an if statement with 3 conditions would look like if you drew it as a flow chart. Alright, so what about our tax calculation program? So now you should be able to write it. So as before we are going to have variable stacks and income and we will read in the income into the variable income. Now if income is less than or equal to 180,000 we are going to say tax is 0 and now we will use the more general if statement. So else that means if this condition is false then we check this condition. If income is less than 500,000 then what do we do? Well then we say that the tax is equal to income minus excess of income over 180,000 10% of that. So that is what this expression is implementing. So remember that this expression is going to be executed if this was false and this is true. So what does that mean? So if this is false then the income is above 180,000. But this is true means the income is less than 500,000. So indeed this statement will be executed only if the income is less than 180,000 but sorry if the income is greater than 180,000 but less than 500,000 exactly as we wanted. But if the income is greater than 500,000 then we come to this part but again we are going to make one more check. If the income is less than 800,000 then the tax is income minus 500,000 20% of it plus 32,000. Again let me indicate when is this statement going to be executed? Well for that statement to execute this condition must be false, this condition must be false and sorry this condition must be false, this condition must be false but this condition must be true and that happens precisely when income is bigger than 500,000 but less than 800,000. And finally if the income is bigger than 800,000 then the last part of a rule gets used which is the excess income above 800,000 30% of it plus 92,000. And so that concludes this if statement. So this general if statement looks very large that is what is concluded and then we print out the tax. I have shown this program the entire program as a flow chart now so first we are going to read in the income then we are going to check is it less than 180,000? If it is then there is no tax, otherwise we check is it less than 500,000? If it is then the tax is 10% of the excess, otherwise we check if it is less than 800,000 so then the tax is as per this box if it is bigger than 800,000 then it is as per this box and at the end we just print the tax. Now I am going to show you a very small modification of the previous program. So far it is the same but here instead of writing else if income less than 500,000 tax is so and so else if income less than 800,000 the tax is so and so. So I would like you to mentally execute the program and tell me whether this program is exactly is doing exactly the same thing as the previous program and I said tell me I mean think for yourself. So for which values of income will it do exactly the same thing? For which values of income possibly will it do something different or in other words if it does the same thing for all values then it is exactly the it is a correct program it is a program which does the same thing as the previous program which we said was correct but if it does something different for some values of income then it is a wrong program and I would like you to tell me whether this program is right or wrong and if so state what error it makes that is for what values of income will it produce an error. So what did we discuss in this segment? We discussed the most general form of if and we used it in our tax calculation program. Next we are going to see more general ways of specifying conditions. So we will take a break.