Java programming methods are special code fragments that represent the actions in whole program coats. So, these code fragments are written in a way that it can be reusing the front part of the program. Before we begin, let's start by enhancing the calculator further if you were to add a standard functionality with an advanced function, so let's say we want to add in summation function, how are we going to add in? Okay, make this make the syntax. So we'll see the follow in order meta syntax. So we can have modifier, return data type, the method name and then we return some Variables are some values that we can have modifier boy then mecha name and then parameters.
If we return data type is void, so we do not have to return anything. Then we can also have modifier return data type meta name and return something, some values and then we don't have any parameters inside a bracket. And the most basic method will be the modifier void method name and statements. So, let's say the right submission method. So, these are public and static is the modifiers. dhaba is the return data type.
Then summation is the method name. integer is integer y is parameters so easy The return data time estaba. So when we return the value issue be also in Java. So, in Java programming the modifier can be public, which means this method class can be accessing on our other clauses. Steady means that there is only one copy of this method or variable in the whole program. So, let's say we want to add in methods into the summation.
Now we want to add in a summation method into our calculator program. So how are we going to a so we'll say we in summation method here, now me a in the case phi here and then we modify these Option less than or equal to four to be modified to option less than or equal to five and we are in a summation here okay so let's see okay menu in the So integer result, so this one should be x is or should be y. So, for integer i equal zero less than or equal to y i plus plus and i see i equals x okay result equals result plus I was equal result plus i i x okay so return result t I like to change this to ba ba, ba ba okay something IDs and we'll say Are we menu five submission the modifier option are less than or equal to five.
So now we are in case by case by where you saw an iba submission. The be number one, TV number two and then C D NSE trial complete cannot be converted to in the past okay. So I can convey to integer now in teacher Number One Nation mec. So this one way, a convert from string to integer and the other way, say Korea integer integers here in the Number one equal dv number in the chaos Okay. See one equal dv number 119 in the Joe talk number one in pager pager number two doc okay integer number one integer number two Okay, try to run the program One to 100 right so get a file file case or submission by one 100 Pfizer or Pfizer or so, this is the correct number. Do you want to answer yes okay.
So, we are, we have come to the end of chapter four. So, in chapter four we have covered a conditional statement, I will say, if else statement and the switch and case statements. Now we have cover loops, how we cover for loops and while loops and then we have covered methods. So, in the next chapter we are going to object and classes are the object oriented programming or Java