We will continue to write the program for solving an equation of the second degree. In the previous video, we have the declaration of the variables. We have declared the initial variables a, b and c, which correspond to the coefficients of the equation ax square plus bx plus c. We have defined the variable delta which corresponds to the discriminant, and the variables x1 and x2 which correspond to the maximum two possible solutions that the equation can have. These variables have been given a name. Here, we decided to use names that correspond to the mathematical notations used in solving a second degree solving a second degree equation. The three coefficients are called a, b and c, the discriminant is called delta, and the two solutions x1 and x2. We also assigned a type to each variable, either explicitly here in indicating that a, b and c are numbers and in this case integers, or implicitly here by assigning a value directly. Obviously, the type of the variable matches the type of the value, so here 0, 0 and 0 mean that delta, x1 and x1 are variables of variables of type integer. The variables a, b and c cannot be be calculated by the program. So we have to provide them to the program, and that's going to be the user's job. We will initialize the variables a, b and c with values that will be provided by the user by the user from the keyboard. And then, delta, x1 and x2 at the start, we'll assign them a value that we'll call neutral neutral, since in fact, we're will successively in the following calculate the delta value, then x1 and x2, which are the result values. We initialize these three variables by assigning them a value which has no particular meaning, which is a neutral value, since it's not going to be their final values. And now, we'll start writing the program, the instructions of the program itself, defining their defining their chronology. In the procedure, we determined that the first thing to do is is to calculate the final delta value. We will define delta, and delta is b squared minus 4ac. Let's build this operation. We'll start with b squared which we'll calculated as b times b. And then, we will determine a times c. We have part 4ac, and we'll put the two together, b square minus 4ac. So delta, once this instruction has been executed, will be the value that will be determined by performing this calculation. This calculation will be done by replacing b, a and c by their values at that time, which are the values that were entered by the user at the beginning of the program. Once this instruction has been executed, delta executed, delta will no longer be worth zero, it will be the result of the execution of this instruction. Once we have delta, we'll be able to determine, to calculate the solutions of the equation. And we know that the way to calculate them will depend on the delta value. So, we'll need a conditional statement which will allow us to test the different delta values. We will test delta in the different different situations. We'll start with the simplest situation if delta is strictly negative. In this case, there is no solution, so we don't have any calculation to do, but we still have to do some processing, which will be to warn the user of the result. And so we will display a message that will indicate : This equation has no solution. Obviously, in the communication that will take place between the user and the program, of course, data must be entered, and then we'll display the results in the other direction. Here, we will have to tell the user that in this situation, there is no solution. We will be able to test the other situations. We could use a second if which will test if delta is equal to 0, then a third if that will test if delta is greater than or equal to 0. But in fact, we will generally use a slightly more complex but more efficient solution more efficient, which is to say to ourselves that if this condition is false, it means that delta is not not strictly negative, which means it's positive or zero. This actually corresponds to the other two other situations we have to test. This corresponds to the situation of the else, and so we're going to add an else here. This otherwise will allow us to deal with the situation where the condition here is false. But this situation corresponds to two situations, so we'll discriminate them too with a second nested if. Here, what we are going to test is to determine in which of the two situations we are in: is it zero or is it positive? equal to zero or is it positive? We will test delta and we will test the second situation Is delta equal to zero? If delta is zero, that means I have only one solution, and I'm only going to use x1 here. We know that when there is only one solution, the value of this solution is equal to the result of the formula minus b over 2a. We will first calculate minus b. We will calculate minus b by minus 1 times b. And then, 2a, [AUDIO_VIDE] and thus minus b divided by 2a. And here too, now that we have calculated, we'll have to display it. We will create a text that will combine an indication : The equation has only one solution, colon. And we'll ask to display. We won't display x1, of course, we're going to display the value of x1. And that's it. Now, if delta is not equal to 0, since it's already not negative, that means that in this case it is strictly positive. The other side of this if will in fact correspond to the third situation. We will add an else, and this else will correspond to the situation where delta is strictly positive. We don't need to re-test is delta positive. If we get to the other way around, it means it's not negative, that it is not equal to 0. So the only solution is that it is strictly greater than or equal to 0. In this case, we know that we have two solutions to calculate: x1 and x2. And the first solution x1 is less b minus root of delta over 2a. We'll calculate 2 times a, we will calculate the square root of delta, we will calculate minus b. Minus b minus square root of delta. And all this must be divided by twice a. We define x1 as minus b minus the square root of delta, the whole divided by 2 times a. And we will simply duplicate this calculation to define x2, knowing that the only difference is that here it's more square root of delta instead of square root of delta. Here again, we will have to display the result. The equation has two solutions which are x1 One more little bit of text here. Of course, we have to display everything this on the screen. Now we've dealt with our three solutions, our three solutions, our three situations. Delta strictly negative, no solution; delta equal to 0, only one solution; and delta strictly positive, we have both solutions. We've finished writing the program. Now we have to compile and test the program. In the following video, this is what we will see, especially the see, especially the testing step. The test step, it's going to consist of running the program with different data for for which the results are known, so that we can compare what the program will give us as results with the results that we know, to to check, to make sure that the program works and does the calculations correctly. [MUSIC]