And the scolding lecture, we're going to have a task where we have to modify the price of a Dodge challenger,
but it could be anything else, movie ratings or a game where we have to modify data.
We're going to go to almost every operators that I introduce to you previously.
We have a lot of things to be covered, so let's do it.
First of all, let's create a new operators class to do that.
Right.
Click on one of the files we have created.
You Java class operators, hard hit enter.
Go back to one of the files we have created before and copied the main method.
Posted here and hit Enter to add the other curly brace.
OK, we also need some variables that we will use, so first string car model equals Dodge Challenger
SRT two and a semicolon and price equals fourteen nine nine nine and a semicolon.
Another end for money in the bank equals one million.
And lost a boolean
is damaged and it's going to be true right then let's start with arithmetic operators.
These are going to be easy ones.
Let's print out the price first.
So system that all print run or so you t and it enter double quotes, price column space and the euro
mark plus price.
Let's create a new variable and end for increased price.
Price increased equals price plus.
A thousand.
And semicolon, let's print out that while you use the line before that one, copy and paste.
And change the text, increased price and change the variable name as well as increased price, the
next one is to decrease the price of copper.
This code posted here, remove the extra line.
So instead of increase, we're going to need a decrease.
And instead of adding a thousand, we're going to remove thousand from the price.
Change the text as well, the increased price and the variable name as well.
Be careful, change everything I change.
Don't miss anything.
The next one will be to cause price.
So Capito's lines.
And changed the name to price to cars and double the price by multiplying price, were we able to change
the text to cars price and change the variable name as well?
Surprise to cars.
OK, so now let's do something extra.
We have money in the bank variable, so let's see how many cars we could buy for this money.
So to do that, double the lines.
Copy and paste.
And.
The variable name is going to be torch torches.
You can buy and we are going to divide the money in the bank variable with.
The price change the text as well.
So doges you doges you can buy for your money column and the variable name is Doges, you can buy and
last.
Let's see how much money we will have after we use all of our money to buy the changes.
Stobo the lines.
Let's change a variable name to money remain equals money in the bank percentage mark and price
and change the tax to money.
I will have.
After buying.
And.
At here, the Dodgers, you can buy plus another tax, George Challenger is.
Column space and you go Mark Class Variable Money Roumain, now run the code.
Let's see how it works.
It's a process, correct?
The increased price and the decreased prices while the two course price is good, too.
So we could buy 66 Dodgers for one million dollar, I mean, damaged Dodgers and the money we would
have after buying 66 such challenges as ten thousand and sixty six euros.
Now, let's move on to radio operators before that, print out a blank line here just to separate the
two operator group.
So system dot org dot printer then.
And that's it creates a negative price first.
So and writes negative equals minus 49 ie nine and a semicolon first.
Let's does the plus sign.
So copy the code from here.
And paste it here, change the variable name to price negative weight loss Sorin and replace this part
with loss and price negative.
Change the text as well.
So negative.
Price with glassine
and change the variable name price Nagati with plus sign and it Panter Let's copy the last two lines
and change the plus to minus.
And the plus side to minus.
And the text as well.
And the variable name is well.
Let's test our code again so Ron and as you can see, the plus sign didn't change anything on our number,
but the minus sign did the job double plus and minus all the next create an end for one zero price change.
So and price one euro Greece equals price.
And double plus sign and they semicolon, bring that out, copied a line from here.
Change the text twice after one euro price increase.
Change the variable as Paul.
Just to test it, run out called.
It seems something went wrong here, but it didn't.
Let's put the double plus sign before price.
Then run it again.
Now, the increased price is correct.
So what's going on here?
If we put the double plus sign before the variable name Java will increase the value of the price first
and then assign the value to price one zero increase variable, if the double plus sign is after the
variable, then Java assigns the value of price.
Forty nine point nine to price one euro increase and then increase is the original price variable value
by one to prove it.
Let's go back to the code and change it back.
To this and print out prices while you.
Original
price after one euro increase and change this to price.
On the cold.
And as you can see, the original price increase to 15000, but the one zero increased price remained
the same.
So now put the plus signs before price.
And run the code again.
Now, both variables have the same value.
Now, let's do the same with decrease.
Copied is code based, change the plus signs to minus.
Increase to decrease, change to text as well as variable names.
And the text here to OK, the original price remained the same, so let's round the code again.
Now we are back to forty nine nine nine zero again, one last operator here and this group is the exclamation
mark that can change the booleans value to another.
We don't need a variable for this.
So it's a standard printer and the car is damaged.
It column and loss.
And we are going to use the exclamation mark here is damaged.
As you can see, this damage here is true.
Now let's run our code.
And because of the exclamation mark, it shows force.
Now, let's all the blank line again, top of this line and move.
This from here.
Move on to the next part, equality and relational operators, this will be a quick one.
Let's start with a system that's out that Princella.
First, we're going to check whether the money in the bank equals to the car's price.
So car's price equal to the money in the bank column and a plus sign.
And instead of creating a new variable, we are going to use parentheses to create a inor variable for
this.
So price equals money in the bank.
Double the line, change the to not equals and change the operator to not equals.
Now let's top of the line again.
The next one will be greater than change the text as well.
Top of the line, again, change the text last year and change the operator as well.
Top of the line again, price.
Greater than or equal to the money in the bank, changed the operator.
Top of the line again.
Change the operator and change rate to less, and the last in this group is our bonus, the instance
of the top of the line, again, change the text to cars
from auto variable.
He's a trained car model, he's tons of string at an extra Blankstein to.
Remove this and from our code.
Let's check the results so the car's price isn't equal to the money we have in the bank and which makes
the next one true and the price is greater than the money in the bank is false, which makes the next
one true.
And it's also not true that it's the price is greater than or equal to the money in the bank.
And the last one is the car's model.
Variable is a string.
And it's true.
Three more to go ternary operator, so as it was in the previous lecture.
String damaged text he calls is damaged, questionmark, the car is damaged, so it will be assigned
to damage text if it is damaged is true.
And calling
the car isn't damaged.
And a semicolon to the end of the line.
So now let's print out the damaged text system that all print on.
And.
Damaged text print out an extra blank line to spell.
Now around the code.
Car is damaged.
It's OK.
We know that.
So let's use the exclamation mark here and change the variables while you run it again.
Now, the car isn't damaged, so we changed its damaged value.
And based on that, the ternary operator assigned another variable to the damage text.
So that's all about an operator.
Let's move on to logical operators.
Computer technology operators called.
Paste it here.
Now let's use logical operators to decide whether it's worth it to see the car, so let's change this
worth seeing message.
I would say if a car is not damaged or the price is less than twenty thousand euros, it is worth seeing
the car.
So how we can do that?
So, as you can see, we already have is damaged and we used exclamation marks.
So it's going to give us a not damaged and that we are going to use the two vertical lines or and if
the price is less than 20000, change the text.
It is worth seeing the car.
It isn't
for sale.
They can't.
Change the variable name here.
Let's run our code again.
It says it's worth seeing the car now use and operator to decide what a damaged car worth repairing.
So double these.
Change the variable name to worth repairing.
So we're going to need a damaged car here.
And changed it or operator to end and the price of a dead, damaged car should be less than 10000 to
change the text as well.
Preparing and change the variable name here to.
And run the code again.
So it says it's not worth repairing the car because the price is too high, it is damaged.
So it's true, but the price is about 10000 to make it through, increase the price to 15 thousand and
run the code again.
Now it's worth it to repair the car.
These numbers might not be true for real life, but we would need a lot of more details about the condition
of the car to decide this.
I use these numbers just to show you how or and and operators can be used.
Finally, the last operator group assignment operators.
We will use the original price variable for this.
So simply type in price plus equals a thousand and a semicolon system that out of print an increased.
Bryce, Colin and the euro mark.
Plus, price doubled these lines.
Now decrease the price with changing the plus to minus and the tax decrease the price and the price
variable name remains the same.
It's now double these lines again.
Now we're going to print out the double price now changed to minus.
And the thousand to two and change the text to the tablet price and the price variable name remains
the same again, copper this.
And now of that price.
And change that doubled to half price and lost couple days and based it here, we'll double and the
percentage mark and we're going to have.
A fan wasn't here and it's going to be the remained.
Price.
Run the code.
Price increase and decrease values are OK, then we doubled the decreased price, then divided by two
to get back the decreased price and last we put the reminder into price variable.
This way we use the original price for every operator in this group.
That's it.
Finally, we are done.
I know it was a long one.
If something is not clear, feel free to ask me.