1 00:00:02,370 --> 00:00:08,430 And the scolding lecture, we're going to have a task where we have to modify the price of a Dodge challenger, 2 00:00:08,430 --> 00:00:14,660 but it could be anything else, movie ratings or a game where we have to modify data. 3 00:00:14,850 --> 00:00:19,690 We're going to go to almost every operators that I introduce to you previously. 4 00:00:19,920 --> 00:00:23,250 We have a lot of things to be covered, so let's do it. 5 00:00:24,000 --> 00:00:27,870 First of all, let's create a new operators class to do that. 6 00:00:27,870 --> 00:00:28,200 Right. 7 00:00:28,200 --> 00:00:30,960 Click on one of the files we have created. 8 00:00:33,000 --> 00:00:40,030 You Java class operators, hard hit enter. 9 00:00:40,410 --> 00:00:45,390 Go back to one of the files we have created before and copied the main method. 10 00:00:50,070 --> 00:00:54,210 Posted here and hit Enter to add the other curly brace. 11 00:00:55,920 --> 00:01:10,890 OK, we also need some variables that we will use, so first string car model equals Dodge Challenger 12 00:01:11,070 --> 00:01:25,380 SRT two and a semicolon and price equals fourteen nine nine nine and a semicolon. 13 00:01:26,130 --> 00:01:37,680 Another end for money in the bank equals one million. 14 00:01:40,050 --> 00:01:41,760 And lost a boolean 15 00:01:44,130 --> 00:01:53,990 is damaged and it's going to be true right then let's start with arithmetic operators. 16 00:01:54,000 --> 00:01:55,730 These are going to be easy ones. 17 00:01:56,280 --> 00:01:58,110 Let's print out the price first. 18 00:01:58,990 --> 00:02:13,500 So system that all print run or so you t and it enter double quotes, price column space and the euro 19 00:02:13,500 --> 00:02:17,280 mark plus price. 20 00:02:18,810 --> 00:02:23,550 Let's create a new variable and end for increased price. 21 00:02:23,550 --> 00:02:32,100 Price increased equals price plus. 22 00:02:33,590 --> 00:02:34,580 A thousand. 23 00:02:36,500 --> 00:02:43,970 And semicolon, let's print out that while you use the line before that one, copy and paste. 24 00:02:44,960 --> 00:02:56,810 And change the text, increased price and change the variable name as well as increased price, the 25 00:02:56,810 --> 00:02:59,200 next one is to decrease the price of copper. 26 00:02:59,210 --> 00:03:05,060 This code posted here, remove the extra line. 27 00:03:05,690 --> 00:03:09,230 So instead of increase, we're going to need a decrease. 28 00:03:09,860 --> 00:03:15,740 And instead of adding a thousand, we're going to remove thousand from the price. 29 00:03:16,520 --> 00:03:25,090 Change the text as well, the increased price and the variable name as well. 30 00:03:26,300 --> 00:03:29,380 Be careful, change everything I change. 31 00:03:29,390 --> 00:03:30,500 Don't miss anything. 32 00:03:31,610 --> 00:03:33,920 The next one will be to cause price. 33 00:03:33,920 --> 00:03:35,540 So Capito's lines. 34 00:03:40,060 --> 00:03:54,190 And changed the name to price to cars and double the price by multiplying price, were we able to change 35 00:03:54,190 --> 00:04:02,860 the text to cars price and change the variable name as well? 36 00:04:03,340 --> 00:04:06,280 Surprise to cars. 37 00:04:06,670 --> 00:04:09,770 OK, so now let's do something extra. 38 00:04:09,790 --> 00:04:16,280 We have money in the bank variable, so let's see how many cars we could buy for this money. 39 00:04:16,300 --> 00:04:19,690 So to do that, double the lines. 40 00:04:21,520 --> 00:04:23,560 Copy and paste. 41 00:04:25,450 --> 00:04:26,380 And. 42 00:04:28,880 --> 00:04:34,210 The variable name is going to be torch torches. 43 00:04:34,340 --> 00:04:46,040 You can buy and we are going to divide the money in the bank variable with. 44 00:04:47,110 --> 00:04:50,750 The price change the text as well. 45 00:04:50,770 --> 00:05:10,060 So doges you doges you can buy for your money column and the variable name is Doges, you can buy and 46 00:05:10,060 --> 00:05:10,380 last. 47 00:05:10,390 --> 00:05:16,840 Let's see how much money we will have after we use all of our money to buy the changes. 48 00:05:17,210 --> 00:05:18,580 Stobo the lines. 49 00:05:21,270 --> 00:05:34,590 Let's change a variable name to money remain equals money in the bank percentage mark and price 50 00:05:37,110 --> 00:05:40,160 and change the tax to money. 51 00:05:41,520 --> 00:05:43,080 I will have. 52 00:05:45,180 --> 00:05:46,860 After buying. 53 00:05:49,540 --> 00:05:50,410 And. 54 00:05:52,730 --> 00:06:03,950 At here, the Dodgers, you can buy plus another tax, George Challenger is. 55 00:06:09,170 --> 00:06:19,350 Column space and you go Mark Class Variable Money Roumain, now run the code. 56 00:06:19,370 --> 00:06:20,660 Let's see how it works. 57 00:06:26,230 --> 00:06:27,690 It's a process, correct? 58 00:06:27,700 --> 00:06:32,920 The increased price and the decreased prices while the two course price is good, too. 59 00:06:33,190 --> 00:06:42,400 So we could buy 66 Dodgers for one million dollar, I mean, damaged Dodgers and the money we would 60 00:06:42,400 --> 00:06:49,900 have after buying 66 such challenges as ten thousand and sixty six euros. 61 00:06:50,680 --> 00:06:56,800 Now, let's move on to radio operators before that, print out a blank line here just to separate the 62 00:06:56,800 --> 00:06:58,390 two operator group. 63 00:06:58,690 --> 00:07:02,380 So system dot org dot printer then. 64 00:07:02,410 --> 00:07:06,910 And that's it creates a negative price first. 65 00:07:07,030 --> 00:07:21,970 So and writes negative equals minus 49 ie nine and a semicolon first. 66 00:07:22,150 --> 00:07:23,800 Let's does the plus sign. 67 00:07:23,920 --> 00:07:25,900 So copy the code from here. 68 00:07:29,130 --> 00:07:46,710 And paste it here, change the variable name to price negative weight loss Sorin and replace this part 69 00:07:46,710 --> 00:07:53,040 with loss and price negative. 70 00:07:54,340 --> 00:07:55,870 Change the text as well. 71 00:07:56,080 --> 00:07:59,590 So negative. 72 00:08:02,520 --> 00:08:06,810 Price with glassine 73 00:08:09,570 --> 00:08:19,350 and change the variable name price Nagati with plus sign and it Panter Let's copy the last two lines 74 00:08:21,750 --> 00:08:24,120 and change the plus to minus. 75 00:08:28,800 --> 00:08:30,390 And the plus side to minus. 76 00:08:32,070 --> 00:08:33,380 And the text as well. 77 00:08:35,530 --> 00:08:37,300 And the variable name is well. 78 00:08:43,090 --> 00:08:49,570 Let's test our code again so Ron and as you can see, the plus sign didn't change anything on our number, 79 00:08:49,720 --> 00:08:58,300 but the minus sign did the job double plus and minus all the next create an end for one zero price change. 80 00:08:58,310 --> 00:09:11,290 So and price one euro Greece equals price. 81 00:09:12,450 --> 00:09:21,440 And double plus sign and they semicolon, bring that out, copied a line from here. 82 00:09:23,900 --> 00:09:35,660 Change the text twice after one euro price increase. 83 00:09:38,580 --> 00:09:40,110 Change the variable as Paul. 84 00:09:44,540 --> 00:09:46,460 Just to test it, run out called. 85 00:09:50,710 --> 00:09:53,900 It seems something went wrong here, but it didn't. 86 00:09:54,080 --> 00:09:57,070 Let's put the double plus sign before price. 87 00:10:02,830 --> 00:10:04,590 Then run it again. 88 00:10:09,070 --> 00:10:10,960 Now, the increased price is correct. 89 00:10:11,170 --> 00:10:12,400 So what's going on here? 90 00:10:12,940 --> 00:10:21,130 If we put the double plus sign before the variable name Java will increase the value of the price first 91 00:10:21,430 --> 00:10:30,430 and then assign the value to price one zero increase variable, if the double plus sign is after the 92 00:10:30,430 --> 00:10:35,560 variable, then Java assigns the value of price. 93 00:10:36,810 --> 00:10:45,060 Forty nine point nine to price one euro increase and then increase is the original price variable value 94 00:10:45,270 --> 00:10:46,800 by one to prove it. 95 00:10:46,830 --> 00:10:50,820 Let's go back to the code and change it back. 96 00:10:53,600 --> 00:10:56,840 To this and print out prices while you. 97 00:10:59,470 --> 00:11:00,430 Original 98 00:11:04,240 --> 00:11:11,560 price after one euro increase and change this to price. 99 00:11:13,630 --> 00:11:14,320 On the cold. 100 00:11:21,460 --> 00:11:29,680 And as you can see, the original price increase to 15000, but the one zero increased price remained 101 00:11:29,680 --> 00:11:30,260 the same. 102 00:11:30,580 --> 00:11:33,190 So now put the plus signs before price. 103 00:11:35,150 --> 00:11:36,380 And run the code again. 104 00:11:41,890 --> 00:11:44,950 Now, both variables have the same value. 105 00:11:47,960 --> 00:11:50,090 Now, let's do the same with decrease. 106 00:11:51,420 --> 00:11:56,610 Copied is code based, change the plus signs to minus. 107 00:11:58,360 --> 00:12:06,850 Increase to decrease, change to text as well as variable names. 108 00:12:10,000 --> 00:12:17,800 And the text here to OK, the original price remained the same, so let's round the code again. 109 00:12:24,770 --> 00:12:33,620 Now we are back to forty nine nine nine zero again, one last operator here and this group is the exclamation 110 00:12:33,620 --> 00:12:37,630 mark that can change the booleans value to another. 111 00:12:37,850 --> 00:12:40,130 We don't need a variable for this. 112 00:12:40,130 --> 00:12:49,880 So it's a standard printer and the car is damaged. 113 00:12:51,290 --> 00:12:54,140 It column and loss. 114 00:12:54,410 --> 00:13:00,050 And we are going to use the exclamation mark here is damaged. 115 00:13:00,260 --> 00:13:02,810 As you can see, this damage here is true. 116 00:13:03,320 --> 00:13:04,850 Now let's run our code. 117 00:13:10,760 --> 00:13:13,910 And because of the exclamation mark, it shows force. 118 00:13:15,700 --> 00:13:20,320 Now, let's all the blank line again, top of this line and move. 119 00:13:21,590 --> 00:13:22,820 This from here. 120 00:13:24,800 --> 00:13:30,350 Move on to the next part, equality and relational operators, this will be a quick one. 121 00:13:30,680 --> 00:13:34,410 Let's start with a system that's out that Princella. 122 00:13:36,650 --> 00:13:41,330 First, we're going to check whether the money in the bank equals to the car's price. 123 00:13:42,050 --> 00:13:59,700 So car's price equal to the money in the bank column and a plus sign. 124 00:13:59,840 --> 00:14:07,250 And instead of creating a new variable, we are going to use parentheses to create a inor variable for 125 00:14:07,250 --> 00:14:07,690 this. 126 00:14:07,700 --> 00:14:14,740 So price equals money in the bank. 127 00:14:16,820 --> 00:14:28,340 Double the line, change the to not equals and change the operator to not equals. 128 00:14:28,520 --> 00:14:30,230 Now let's top of the line again. 129 00:14:30,470 --> 00:14:35,890 The next one will be greater than change the text as well. 130 00:14:39,990 --> 00:14:48,580 Top of the line, again, change the text last year and change the operator as well. 131 00:14:49,530 --> 00:14:51,750 Top of the line again, price. 132 00:14:56,860 --> 00:15:05,560 Greater than or equal to the money in the bank, changed the operator. 133 00:15:08,220 --> 00:15:09,570 Top of the line again. 134 00:15:12,940 --> 00:15:24,190 Change the operator and change rate to less, and the last in this group is our bonus, the instance 135 00:15:24,190 --> 00:15:31,640 of the top of the line, again, change the text to cars 136 00:15:34,620 --> 00:15:38,080 from auto variable. 137 00:15:41,650 --> 00:15:54,010 He's a trained car model, he's tons of string at an extra Blankstein to. 138 00:15:56,770 --> 00:15:59,710 Remove this and from our code. 139 00:16:03,000 --> 00:16:10,140 Let's check the results so the car's price isn't equal to the money we have in the bank and which makes 140 00:16:10,140 --> 00:16:17,580 the next one true and the price is greater than the money in the bank is false, which makes the next 141 00:16:17,580 --> 00:16:18,620 one true. 142 00:16:19,020 --> 00:16:26,730 And it's also not true that it's the price is greater than or equal to the money in the bank. 143 00:16:27,010 --> 00:16:30,600 And the last one is the car's model. 144 00:16:30,720 --> 00:16:32,250 Variable is a string. 145 00:16:32,250 --> 00:16:33,420 And it's true. 146 00:16:34,660 --> 00:16:39,970 Three more to go ternary operator, so as it was in the previous lecture. 147 00:16:43,590 --> 00:17:03,060 String damaged text he calls is damaged, questionmark, the car is damaged, so it will be assigned 148 00:17:03,060 --> 00:17:06,440 to damage text if it is damaged is true. 149 00:17:08,570 --> 00:17:10,220 And calling 150 00:17:12,800 --> 00:17:18,200 the car isn't damaged. 151 00:17:21,780 --> 00:17:24,130 And a semicolon to the end of the line. 152 00:17:24,480 --> 00:17:30,390 So now let's print out the damaged text system that all print on. 153 00:17:33,750 --> 00:17:34,470 And. 154 00:17:36,630 --> 00:17:41,880 Damaged text print out an extra blank line to spell. 155 00:17:44,880 --> 00:17:45,900 Now around the code. 156 00:17:50,960 --> 00:17:51,910 Car is damaged. 157 00:17:52,030 --> 00:17:52,530 It's OK. 158 00:17:52,670 --> 00:17:53,370 We know that. 159 00:17:54,080 --> 00:18:01,820 So let's use the exclamation mark here and change the variables while you run it again. 160 00:18:02,630 --> 00:18:07,600 Now, the car isn't damaged, so we changed its damaged value. 161 00:18:07,610 --> 00:18:13,900 And based on that, the ternary operator assigned another variable to the damage text. 162 00:18:14,190 --> 00:18:16,150 So that's all about an operator. 163 00:18:16,190 --> 00:18:18,230 Let's move on to logical operators. 164 00:18:18,740 --> 00:18:20,900 Computer technology operators called. 165 00:18:22,450 --> 00:18:23,230 Paste it here. 166 00:18:23,530 --> 00:18:33,070 Now let's use logical operators to decide whether it's worth it to see the car, so let's change this 167 00:18:33,280 --> 00:18:38,050 worth seeing message. 168 00:18:43,720 --> 00:18:50,080 I would say if a car is not damaged or the price is less than twenty thousand euros, it is worth seeing 169 00:18:50,080 --> 00:18:50,650 the car. 170 00:18:51,070 --> 00:18:52,510 So how we can do that? 171 00:18:52,520 --> 00:18:58,840 So, as you can see, we already have is damaged and we used exclamation marks. 172 00:18:58,850 --> 00:19:07,960 So it's going to give us a not damaged and that we are going to use the two vertical lines or and if 173 00:19:07,960 --> 00:19:15,040 the price is less than 20000, change the text. 174 00:19:16,750 --> 00:19:22,600 It is worth seeing the car. 175 00:19:27,640 --> 00:19:28,840 It isn't 176 00:19:31,690 --> 00:19:34,830 for sale. 177 00:19:37,510 --> 00:19:40,630 They can't. 178 00:19:46,180 --> 00:19:47,720 Change the variable name here. 179 00:19:49,750 --> 00:19:51,120 Let's run our code again. 180 00:19:52,560 --> 00:20:01,110 It says it's worth seeing the car now use and operator to decide what a damaged car worth repairing. 181 00:20:01,650 --> 00:20:03,450 So double these. 182 00:20:06,880 --> 00:20:12,420 Change the variable name to worth repairing. 183 00:20:18,830 --> 00:20:21,560 So we're going to need a damaged car here. 184 00:20:23,060 --> 00:20:31,150 And changed it or operator to end and the price of a dead, damaged car should be less than 10000 to 185 00:20:31,160 --> 00:20:32,650 change the text as well. 186 00:20:40,530 --> 00:20:44,130 Preparing and change the variable name here to. 187 00:20:47,190 --> 00:20:48,600 And run the code again. 188 00:20:52,820 --> 00:21:00,070 So it says it's not worth repairing the car because the price is too high, it is damaged. 189 00:21:00,080 --> 00:21:11,420 So it's true, but the price is about 10000 to make it through, increase the price to 15 thousand and 190 00:21:11,420 --> 00:21:12,420 run the code again. 191 00:21:13,100 --> 00:21:15,920 Now it's worth it to repair the car. 192 00:21:16,070 --> 00:21:22,700 These numbers might not be true for real life, but we would need a lot of more details about the condition 193 00:21:22,940 --> 00:21:24,700 of the car to decide this. 194 00:21:25,130 --> 00:21:30,740 I use these numbers just to show you how or and and operators can be used. 195 00:21:31,520 --> 00:21:35,300 Finally, the last operator group assignment operators. 196 00:21:35,540 --> 00:21:38,630 We will use the original price variable for this. 197 00:21:39,020 --> 00:21:54,230 So simply type in price plus equals a thousand and a semicolon system that out of print an increased. 198 00:21:57,750 --> 00:22:02,160 Bryce, Colin and the euro mark. 199 00:22:05,170 --> 00:22:08,920 Plus, price doubled these lines. 200 00:22:12,610 --> 00:22:24,370 Now decrease the price with changing the plus to minus and the tax decrease the price and the price 201 00:22:24,370 --> 00:22:26,000 variable name remains the same. 202 00:22:26,650 --> 00:22:28,780 It's now double these lines again. 203 00:22:33,940 --> 00:22:38,620 Now we're going to print out the double price now changed to minus. 204 00:22:41,670 --> 00:22:51,630 And the thousand to two and change the text to the tablet price and the price variable name remains 205 00:22:51,630 --> 00:22:54,360 the same again, copper this. 206 00:22:57,180 --> 00:22:59,580 And now of that price. 207 00:23:01,670 --> 00:23:13,550 And change that doubled to half price and lost couple days and based it here, we'll double and the 208 00:23:13,550 --> 00:23:17,390 percentage mark and we're going to have. 209 00:23:18,360 --> 00:23:24,410 A fan wasn't here and it's going to be the remained. 210 00:23:27,180 --> 00:23:27,870 Price. 211 00:23:30,400 --> 00:23:31,180 Run the code. 212 00:23:32,270 --> 00:23:40,070 Price increase and decrease values are OK, then we doubled the decreased price, then divided by two 213 00:23:40,220 --> 00:23:47,510 to get back the decreased price and last we put the reminder into price variable. 214 00:23:47,810 --> 00:23:52,730 This way we use the original price for every operator in this group. 215 00:23:53,510 --> 00:23:54,200 That's it. 216 00:23:54,230 --> 00:23:55,430 Finally, we are done. 217 00:23:55,460 --> 00:23:56,750 I know it was a long one. 218 00:23:57,160 --> 00:24:00,110 If something is not clear, feel free to ask me.