 Hello everyone, myself Professor Pratish Chittay working in mechanical engineering department Valchandristhuap Technology Solapur. In our fifth session we will discuss branching looping in Java programming. The learning outcomes are at the end of the session the students will be able to explain the different types of branching looping with their syntaxes and they will execute the programs regarding branching and looping. What we will see in this session? First we will see the short recap of fourth session. After that we will see what are the different types of branching and looping and the programs based on the branching and looping. In the fourth session we have discussed the different mathematical functions. After that we have discussed the different programs based on the mathematical function like how to calculate the area of triangle and how to calculate the roots of quadratic equation. Now in this session we are discussing branching and looping. What are the different types of branching and looping? It consists of if else statement, for loop statement and do while statement. What is mean by if else statement? The if else statement consists of so this is the general syntax for the if else. If suppose you are having the condition for example x less than 0 and suppose it is true this condition is true means this statement will be printed that statement 1 will be printed otherwise the else statement will be printed. This might be a false statement but if this particular condition is true means your statement 1 will be printed otherwise else statement 2 will be printed. Here you can see in the figure it is the algorithm for the if else statement. If the condition is true the if code statement will be printed and there will be the exit of the program means this statement will be printed otherwise whenever it is false so else a code that is else a statement will be printed and it will be ended there will be the exit from the program. So with the help of this you can solve very simple programs. In the last session we are discussing regarding the mathematical function how to calculate the roots of quadratic equation but we have never checked that the roots are real or not. So in this if else statement we will take first we will check the roots of the quadratic equation they are real or imaginary and after that we will calculate the roots of quadratic equation. We have calculated the roots of quadratic equation but we do not have checked the roots of quadratic equation. So the problem statement is write the program to check the whether the roots of the quadratic equations are real or imaginary we are having the quadratic equation and also we are finding out the roots of quadratic equation. This is the formula. We'll go to the program first. Roots 2 is a class name. Public static void means string ARJS is a main statement. X, that is the one variable we have declared. A is equal to 2, B is equal to 10 and C is equal to 4. These are the values for the roots that is ABC. Now here we had recall those values that is ABC. Now we are having the formula like minus B plus or minus under root B square minus 4 AC. So we will check that B square minus 4 AC value. So here we will first calculate the B square minus 4 AC value in the program. So X is equal to that is capital X is equal to B square minus 4 AC that we have declared here. So B square minus 4 AC and after that after calculation and the storing of this particular value we are printing that particular value that is capital X by plus X. So system dot dot dot print L and X is equal to plus X. So with the help of plus X the calculated value will be printing here. After that we are checking that the roots are real or not by X less than equal to 0. If suppose this B square minus 4 AC value is greater than 0 means the roots are real. Otherwise if X less than 0 means the roots are imaginary. If X less than is equal to 0 the roots are real. After that only we can go to the particular roots of the quadratic equation. Suppose the roots are real after that. So X is equal to minus B plus for the first root of the equation minus B plus mat dot square T in the bracket S divided by 2A. So X is equal to B square minus 4 AC. So mat dot square T that is under root of B square minus 4 AC. So mat dot square T here we have used the one mathematical function. Here will be the calculation for the X1 that is the first root of the quadratic equation. So system dot dot print L n is equal to root 1 is equal to plus X1. So plus X1 will be the this particular value the first root of the value. Here for the quadratic equation for the second root that is minus B minus mat dot square T X divided by 2A. So this is the particular formula with the help of this we can calculate the X2. But it is only possible whenever the roots are real. And suppose the roots are imaginary it will go to the directly to the L statement. It will be printing like imaginary roots when your X is less than 0. Now we will take the output from this program go to the DOS front. In the DOS front my code will be javac that is compilation code roots2 dot java that is my filename javac space filename that is roots2 dot java enter. So java is a two step process after that you have to interpret that to execute the program. So java space roots2 this is a class name. So here the roots are real because we got X greater than equals to 0 greater than 0 that is X is equal to 68 that's why there is a printing of the particular statement that X the roots are real after that only there will be the calculation of root 1 and root 2. So this is the very simple program regarding the if else statement. Now again we will move to the the PPT nested if else in the if else only we have checked that if else statement. Now what is meant by nested if else statement if suppose there are the more than one condition. Now what is the general syntax for the nested if else if suppose your condition 1 in the if condition if the condition 1 is true your statement 1 will be printed and everything will be stopped there will be the exit of the program. But if suppose your condition 1 will be wrong it will go to the else if statement that is if else statement the condition 2 will be checked and suppose this is true it will go to the statement 2 and it will be printed because this is the true statement and after that there will be the exit of the program. If suppose your condition 2 is false means it will go to the else statement or it will go to the condition 3 if suppose the your condition 3 is true means your statement 3 will be printed because this is the true condition and if suppose your condition 1 condition 2 condition 3 is false it will go to the directly to the else statement and your statement 4 will be printed. We will see the algorithm for the nested if else here after starting the program it will go to the if condition if suppose it is true the statement after if will be printed and it will the exit of the program. Otherwise if it is false it will go to the nested if condition and the true statement will be printed it will go to the after if statement that will be printed and it will go to the exit. Again if suppose it is false directly it will go to the else statement. So, here there are the only one else if statement here we are having the two else if statement condition 1 condition 2 and condition 3 are the if statement if suppose these are false the else statement will be printed directly because these are false. Here the two else if statement one is suppose it is true it the there will be the printing of this particular statement it will be the exit of the program if suppose the if statement is false it will go to the nested if else statement and if it is suppose true it will be the directly printing and that will be the exit but if it is suppose both are false it will it will directly go to the else if statement and that will be the exit of the program. Now you are having very simple question what is the difference between else if statement and if statement just think for this question. Now we take Wins simple program regarding the lcp statement write the program to check whether the student is passed with the distinction or the fail with the help of following conditions you are having the following conditions. So, as we have discussed the syntax for the nested if else first the p is 65 here we have provided. So, we have to print that particular percentage obtained is 65 now first if suppose p is greater than 70 if suppose p is greater than 70 this is true value means the grade is equal to distinction that will be printed but if suppose this is false else if statement it will go through. So, that is if suppose percentage is between 60 to 70 if suppose this is true means your grade is equal to first class this statement will be printed otherwise it will go to the again the lcp statement that is our third condition that is the percentage is between 50 to 60. So, that will be the second class if it is true but if suppose these three conditions are false it will go to the directly to the grade is equal to fail. Now we will check the output here we have provided the if statement lcp statement also the lcp statement we will go to the directly execution of the program now. So, java c space the name of the file that is marks dot java enter for the execution of a program java space marks my class name. So, we have provided the percentage as a 65. So, the grade will be the first class. So, this is the nested if else program we will go to the ppt here these are the references thank you.