 Welcome to Intro to AP Computer Science for a new AP teacher. This topic is math and variables. Let's go ahead and get started. So topics in this video are math operators, the order of operations, increment, and decrement, combined assignment operators, and the math class. Again this video is not to teach you how to do these things. You are assumed to know them or if not I have another set of videos that does explain these things in detail. It's just kind of an overview of the topics and maybe some things to think about as you are teaching it. So the first one is the math operators. So we have addition, subtraction, multiplication, and division. Of course point out to the students that multiplication is an asterisk. Some students might not know where that's at in the keyboard. On mine it's shift 8, but on others it might be in a different spot. And then that division is the I guess that's the forward slash I believe. And then the modulus, the percent sign. Again students might not be familiar with that. So you definitely want to go over some examples. So the one here on the screen is five percent three or five modulus three equals two because it gives you the remainder. Three goes into five once and there is two left over. Also be sure to point out integer division. There are definitely questions, AP type multiple choice questions that this will be a factor. So five divided by three equals one. So if you ask the students usually what I do is I say well what's five divided by three and they'll say well it's one point six six six six six six and then I'll say okay well let's try it put it into Java we'll run it. We get a one then we talk about why that happens. Okay so you have to tell it so the students realize that okay well if I need that level of accuracy if I need point six six six six six six I'm gonna need to use a double data type in this case. And then this is super duper important as well. There are definitely gonna be multiple choice questions about this subject. The order of operations. Now most students should be familiar with this from their math classes but some may not be. In America at least when I learned it I learned PEMDAS. Please excuse my dear Aunt Sally. I actually do have an Aunt Sally. I messed her on Facebook the other day as a matter of fact. My British students with British backgrounds they use bid mass and I think it means brackets, indices, division, multiplication, addition and subtraction. So basically you know the order of operations we start with parentheses then we do our exponents then multiplication and division. Notice they're on one line so if you have multiplication and division in one equation you go from left to right. Okay so that's why in bid mass the D and the M are reversed whereas in PEMDAS it's M and D, bid mass it's D and M. And then finally addition and subtraction are at the end. Again those are if they're both it's left to right. The actual order of operations in Java is very complex. If you take a look at my e-book I talk a little bit more about that. It's yeah it's pretty involved but this is this is the major thing that most students will have to deal with. They don't really give you anything too much more complex than this. Next one is increment and decrement. So basically we're just talking about adding by one or subtracting by one. So in Java we have x plus plus and we have x minus minus. I just chose x of course whatever integer that would be. Also works with doubles. So this is what you'll see on the AP exam. This is called the post fix. You also see I tell the students because if they're googling if they're getting stack overflow they might see plus plus x or minus minus x. Again the book has an example of why that's important what difference is so but the prefix one plus plus x and minus minus x is not on the AP exam. So they don't have to worry about that one. So they'll only see x plus plus and x minus minus. Along with that is the combined assignment operators. So we could do x plus plus. We could do x equals x plus one same thing. We could do x plus equals one. So we're combining the increment and the assignment into one symbol. By the same time we have x minus equals two x times equals three x divided equals four and x modulus equals five. So they can combine that those into one statement. I like to do that. It just makes your code a little bit shorter maybe a little more clearer but they are welcome to you know write out the longer version. There's no point penalty for that. They can just do it as they wish. And then finally in this section there's the math class which has some functions or some methods that we can use. Basically the two big ones are math.power which is power. So notice that it takes a double so 2.0 and 4.0. So that's the same as 2.0 raised to the 4.0 power. So that's two times two times two times two or 2.0 times 2.0 etc etc. So that should give us a two times two is four times two that gives us 16. And then math.square root for example 25.0 that will give us of course 5.0. Now there are others there's sine cosine tangent. There is a math class method to convert radians to degrees and degrees to radians. You may not need those. They're not on the AP. They're not part of that AP subsection. But you know students may find them useful for writing their own software to help them in their other classes. It's one of the things I try to get the students to think about is well okay in your math class could you use any of these functions to help you with your homework for example. But don't tell them I teach you that. And then there's there's a few constants such as math.pi. Notice the pi is capitalized. There's also math.e which is Euler's number 2.7 blah blah blah whatever it is. Okay so there is this built-in math class that helps you obviously with math functions. So yeah so that was our topics. We looked at the math operators, the order of operations, increment and decrement, combined assignment operators and the math class. And then for an introductory exercise one of the things after I talk about all these things I like to do is just ask the students to brainstorm a bunch of mathematical formulae from their math and science classes. So they might come up with you know force equals mass times acceleration. They might come up with you know calculating the angle based on you know like sine cosine all that kind of stuff. I'm not that familiar with it myself. I think earlier in the book at least there's a section about doing area. So just kind of come up with different formulas that they would have used in a different class. And then in you know you can write those on the board you know what's named the formula. And then in pairs I like to do the pairs and I do this on paper not on the computer. Have them write those formula in Java code and then they can share it and then if there's a group that's done ahead of time then I have them start coding it into the computer. This is a pattern that I do a lot is we do it on paper. Well we talk about it. They do it on paper first because they got to get used to doing that for the AP exam and then they do on paper then they do it into the computer because that helps I think really cement the ideas. And they seem to like it. They seem to like working together and honestly at least at my school we're on the computers far too much and any chance I can to get them off the computer is a good one. So that is that. I think I did I already did the summary so let me just skip past that and we are at the end. Thanks for watching. Talk to you soon.