So here as you can see our application is running on the emulator.
So now let's actually assign a value for this and Bill amount for example one hundred.
And now as you can see the tip is $25 and the total is 125 because here we specified that the percent
is going to be 25 percent.
So I can actually change this value to another value for example 10 percent.
And as you can see here these values are changing the tip is now $10 and the total value that the user
should pay is actually $110 right.
So hopefully this makes sense.
And now let's actually vote on our savings calculator here.
So now let's go back to our jobs file here and now as you can see I actually created these valuables
here inside our main activity class for example in line 24/7.
We have this valuable which is of type double total salary.
So this total salary is going to be the salary here that the user assigned is what you hear right.
And here we have these savings percent as you can see here.
So these savings percent variable which is of type double is going to actually hold the value of this
percent.
So when the user actually sits on the search bar it is going to actually change the value of this percent
and then we can actually save that value.
We can hold that value here inside this savings percent variable.
And according to these savings percent and according to the salary that the user enters here we can
actually calculate the value or the money that the user is actually saving.
OK.
Or the use that one to save.
Right.
So this is going to be our savings calculator.
So we have this total salary savings present and we have to take suffuse for this first.
The first one is for this save a person here this person here.
And the second one is takes the money saved.
And the second one is for this actually takes few here as you can see.
So now first of all let's go inside this uncreate method here and after these lines of code here as
you can see we have two handlers for actually this takes edited out and we have another handler for
this sequel person.
So we need two more handlers inside this uncreate Mefford.
So now I'm going to pace seen some lines of code here and then I'm going to explain to you what's going
on here.
So as you can see here these are lines of code that I pasted here.
First of all I created this line of code here as you can see I created an object of type a text.
And this time the name of my editor is actually his salary so he had to actually create an object for
this as he takes here as you can see here it is salary so assignment operator.
And here I am actually testing this object to an edit text object find view by ID or that ID that it
salary.
Right.
And here in line 66 it salary.
So here I actually referred to the name of this edited edit text object it itself essentially that takes
change listener.
So here I want to actually make this less this it takes actually a listener.
OK.
To what happens inside these edits for example when the users at or actually move some values from this
editor.
You want to actually know what's going on here we want these it takes to be aware of what's happening
inside these text.
So that's why they actually put this line of code here.
It is clearly that add text change to listener.
And here as you can see I actually put this value here.
It is decidedly changed.
KC's watcher so this is going to be the name of our handler which we haven't actually put this.
We haven't actually defined it is handler here.
Yet inside our class and here in line 68 as you can see I actually created an object of type search
bar and the name of my object is search bar save percent assignment operator.
And then here I am actually testing this object to a simple object find view by ID or that ID that seach
part save percent as you can see here.
So here let me disappear.
This virtual keyboard here as you can see we have this part here right.
So here I created an object of type each part and then I referred to the ID of these people here.
So in 1969 here I refer to the name of our object seek birthday present that said unsichtbare chain
to the center.
So again I want to be aware.
I want to actually know what the what is going to be the value of this Sebarenzi use that actually seeks
on the part here.
Right.
So that's why I actually put this line of code here such Percy percent that set on six part change the
center.
And that I actually put this value here in this name so bar savings percent change listener.
So this is going to be again the name of our handler.
So first of all let's actually create this handler and then we're going to go ahead and create this
handler here.
So now as you can see let's actually scroll down here and after.
And as you can see here inside this class inside is main activity class and before the end in calibers
of this main activity class here as you can see we're going to actually put our own code here.
So now let me create a comment savings person savings calculator logic OK.
So here I got a pasting sometimes some lines of code here and then I'm going to explain to you what's
going on here.
So as you can see here these are the lines of code that I pasted here and now I'm going to actually
explain to you what's going on here.
Exactly.
First of all as you can see we have this private access modifier and we have to find out which which
means that this is actually a constant and the data type of a handler is actually the text Wotcher and
the name of our handler is EDT salary changed text bocher the same name that you specify here inside
this uncreate method.
Here as you can see it is Elodie changed text watcher.
So let's go back to our handler here.
So assignment operator new text watcher.
OK so now it's going to actually create an anonymous inner class and that anonymous class is going to
actually implement these text watcher interface and then it is going to actually implement these methods.
These are abstract methods that are inside these texts which are in interface.
So now if we actually hold the comments on my keyboard or the if you are using a Windows machine you
need to hold the control key on your keyboard.
And then I just click on the states which are here as you can see this is actually an interface right.
And here we have some methods inside this interface as you can see here before text changed on text
change and after the text changed.
Right.
So these are the facts that are inside this text which are inside the interface.
So let's go back to our main activity file here.
So now these are them if it's before the exchange so we don't need that for here.
And here is our Meffert on takes changed.
We use this method here and we also don't use this after taste change year aftertaste change Meffert
you're right.
So now let's go inside this text change method and here as you can see I have this try catch block here.
And here's try.
So let's go inside the curly braces of destroy black.
And here are you referred to the name of this variable that I created inside this main activity class.
So let's go back to our class here as you can see I actually created this variable here.
This variable is of type double.
And then I assigned this value zero point zero to the value of it.
So now here are you referring to the name of that variable assignment operator.
And then you refer to the name of this double class that parse double.
So I actually called this parse double method on this double class so this is actually this method is
actually a static method.
Right.
And this method actually accepts an argument of pipe string.
So then it's going to actually convert that string value to a integer value or double value as you can
see here.
Double the pulse double if you wanted to use Integer instead of double we needed to actually call integer
that parse integer.
Right but here it's going to actually convert this string value to a double value.
And here in say the apprentices as you can see here refers to the name of this argument that we receive
from this text change method so s that is 3.
So as you can see here this argument is of type chart sequence right.
So we need to convert that value to a string value.
And as I told you before this value is actually the value that we actually assign to these Eadie text.
Right.
For example number two number three or other values.
This is going to be this is which is off the chart sequence.
And here we are actually converting that by twisting value.
And here by using these parts double Methody are converting that string value to a double value.
And then we can assign that double value to this total salary.
And here as you can see we have this catch plug here and this church is going to actually catch the
errors that are actually number format exception as you can see here.
So for example the user might assign a value that is actually not a not a numeric value.
Right.
So in that case it's going to actually execute this Cheche plug.
It's going to execute this check catch plug and then it's going to assign this number point zero.
This number is zero point zero to this total salary.
Right.
So in that case in that specific case it's not going to actually crash.
OK.
We are catching this error here so hopefully that makes sense.