AP Computer Science Lesson Introductory Java Language Features (2)

in education •  7 years ago  (edited)

Notes Intro Java Language Features - Operators 8/16


####Arithmetic Operators:

"+"Addition-
"-"Subtraction-
"*"Multiplication-
"/"Division-
"%"Mod (remainder)Ex. 11 % 8 = 3

** Keep in mind, if you use int for 5/2... It will give you an integer! So, use double as its type.


Relational Operators:

==equal toEx. if (x == 100)
!=not equal toEx. if (x != 100)
>greater than
<less than
>=greater than or equal to
<=less than or equal to

** Use these when you may need to use different operations to different types of numbers.


Logical Operators:


** AND means both have to be true.
** OR means one has to be true.

Truth Tables


Assignment Operators:

=x = 2-
+=x += 4this means x = x + 4
-=x -= 4this means x = x - 4
*=x *= 4this means x = x * 4
/=x /= 4this means x = x / 4
%=x %= 4this means x = x % 4

Increment and Decrement Operators:

++i++means i = i + 1
--i--means i = i - 1

** Here is a mathematical example where we could use this:


A mathematical program:


Output (what the user would see):
Solving 5+3*2-2^2:
7


Question for the Students

Make a program with the output:
Hello World.
My name is ______.
My favorite movie is ______.

Answer:


Thank you for viewing Steemers! I am happy to provide my lesson plans for you!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

@hansenator - Sire, this is a valuable guidance for java lovers. Therefore, I will RESTEEM & UPVOTE your post Sire.

+W+

Thank you steemwija! I really appreciate the support! Here to educate!

LOL...this brings me back...In high school I helped my older brother with his CS2 class which was in Java. That's how I learned Java. Then I decided to take the AP computer science test after reading about it a bit online and deciding it was pretty basic. My school ordered the test for me (despite not having a class) and I took it in a small room with a proctor...I got really sick that day and vomited 3+ times during the test and had to skip the AP calculus test the next day and a band concert we had that night. (I was able to make up the calc test later)

Long story short, I got a 5, but it was a pretty shitty day...

Wow. Sounds like a hell of a day. Haha. You sound like me in high school... I was the guy people went to for math help. Good work though! What are you doing now?

I'm a senior in college at UMD (Duluth, MN) studying math and computer science. (And playing around with crypto in my spare time)

good news

@hansenator,
When I was at my graduation I did those java stuffs, then started my career as a Java Software Engineer. But life is not as we always thought, I still remember those stuffs, but now doing something much more interesting than codings.
Actually, I hate to be a software developer. I won't take that much of stress, so changed the destiny at the right time.
Good post for newbies of Java, thanks for sharing your knowledge with STEEM community!

Cheers~

Thanks for the awesome comment guru!!! Glad you are doing better than a Software Engineer! You must be really well off! Best wishes ~ hansenator

good post.It is very informative

Thank you kishore1998! I taught this lesson today. It's a great way to make a post.

Thanks Hansenator.I just resteemed two posts feature 1 & feature 2 .Hope your post will reach wider in our community.

Thank you! Best Steemit wishes!

I couldn't ask for more.It is very nice of you .Thanks a lot.

I just send your post to bellyrub.Please accept it as a token of gratitude hansenator.I will encourage your posts to my best.

I appreciate it kishore1988! I'll see you soon!

This post has received a 0.36 % upvote from @bellyrub thanks to: @kishore1988.

Thanks for the information can be of great help

I hope so! More to come!