# Operators Continued, Logical Expressions, Conditional Statements

Today we have gone through shorthand operators.
• class = class + newstudent; can be written as: class += newstudent;
• The same applies for -, *, /. For example: x /= 10; is the same as x = x / 10;
• n = n + 1; may be written as n++; or ++n;
• Know the difference between n++ and ++n.
• int x, n = 7;
x = 3 * n++;

At the end, x = 21, n = 8.
• int x, n = 7;
x = 3 * ++n;

At the end, x = 24, n = 8.
We then went over relational operators:
• > Greater than
• < Less than
• >= Greater than or equal to
• <= Less than or equal to
• == Equality
• != Inequality
As well as logical operators:
• && and
• || or (these two are pipes, can be typed by pressing shift-\ on your keyboard)
• ! not

Conditional statements
if else conditional statements are covered today. Know how to use each of the following:
• if (condition)
program statement
• if (condition)
program statement
else
program statement
• if (condition) {
program statements
program statements
}
• if (condition) {
program statements
program statements
} else {
program statements
program statements
}
Classwork program #1
Write a program that calculates the net pay for its employees. The inputs are number of hours worked and the hourly rate. The company you are writing this program for is very generous and pays its employees time and a half for all hours worked over 40. State tax is 10% and the Federal tax is 23%. Net pay is computed by subtracting both taxes from the gross pay.

Sample output of this program:
```What is your name?
Enter the rate:
Enter the hours:
Name your net pay will be XX dollars!!!
```
Nested if statements
if statements can go into one another. For example:
```if (condition) {
statement1;
if (condition)
statement2;
}
else
statement3;
```
else if statements
With multiple conditions that cause different outcomes, you can use else if statements. For example:
```if (score > 89)
else if (score > 79)
```What is your transaction amount?