Thought loop stem running Java programming language, the loop size yourself instruction to create repetative tasks in Java programming. For instance, if you want to write a program that display numeric digit from one to 1000 EOB as all stiff to write 1000 times off System dot out dot println i. So if I example, System dot out dot println I want System dot out dot println I do until System dot out dot println I 1000 loops are introduced in Java programming in Java. We have two types of loop statement, one is the for loop and the other one is the while loop. So, the following define the syntax of these two loops. So, for follow up for initialization And then in quotation there we have a statement here.
So, for example, for integer i equals zero, i less than three then I prosperous. So, System dot out dot println ii.to string. So for i equals zero, I equals zero is the initialization, then condition is i is less than three, I will say let's say I is lower than three then you will increment i by one. So, in this for loop example, we will have 012 So, we have less than three. So, we have one element to elementary element so is i less than three, beginning from zero for a while loop he will be here The other way so why question and then the statements. So for a while, we need to put in let's say, ah, initialization before this last statement, so you'll be integer i equals zero here, then a while i less than three, then i plus plus inside recess.
Well now let's see how we can modify our calculator to include our loop statement okay. So we add in a string, he says z equal to n. So what is as it equals r n So, that means if this stream very soon where he says is equal to n then we will continue to look this console calculate costs okay and do the Undo we have seen this statement here System dot out dot println operation compared to your one to z. So, if the user type y here is as equal to y then the loop with the levee broke gonna break up. If not ah the criterias D need to execute it will go on So I will say last modified for now. Okay. Stream is as easy equal to n. So heel wha is z. I will say in Java you use r dot you k dot equals two okay.
Key is to be here. So we close the loop here ah So the shoe the asking, do you want to continue here? system dot out, dot print line. Do you want to continue so it should be wise Okay, so I will say we will easy he says equals SC dot x k. He says d equals SC dot mix Okay subtraction I do division one and five 0.2 do you want to continue? I if I put no then you will loop again asked me to enter input so I will choose a subtraction. One, two.
So do you want to continue if I choose yes I will say you as it a program so, I will Tina issue, not be Do you want to continue? It should be Do you want to as it? family, I run the program again. Okay, so we have options here. So let's say now I choose product ones times by. Okay Do you want to as I choose?
Yes. Okay, so now everything is correct okay.