
JAVA
1. Print statements
Print statements are used to print text out on your screen (console).
Practice!!
2. Variables
variables are one of the most important building blocks of java. everything in java is dependent on variables.
Practice!!
3. User Input
Prompting the user to give input for your program can be done in several ways, however, the most efficient and easy way is through "scanner".
​
First, make sure that you import scanner into your class, this can be done at the beginning of the program by typing " java.util.*; " or " java.util.Scanner;" or if you are using eclipse you can shortcut Ctrl + Shift + o after initializing the scanner.

Practice!!

4. If statements
If statements are exactly what they sound like, if a condition is met then the program will run whatever is in the brackets if its false it will move forward. the structure for an if statement is is -
if (*condition*)
{
*whatever that is in here will run*
​
}
Practice!!
5. While loops
While loops are another common loop type in java and are used very often. The dictionary definition is somewhere along the lines of - a while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. in simpler terms, a while loop is just a repeating if statement. until the condition is set to false the loop will keep repeating itself.
​
​
​
The syntax is :
while(*condition*){
*everything in here repeats itself until while loop is terminated
}
​
​
Example-
int a = 0; // variable that we are going to use to make the condition up
while (a< 5) // if a is smaller then 5, the contains of the while loop will keep running
{
System.out.println(a); // prints te value of a
a++; // increases the value of a one every time the program runs
}
​
​
Output :
0
1
2
3
4
Practice!!
6. Nested if loops



7. Accumulation






8. Sentinel controlled loops


9. Nested Loops
Then in the main method initialize a scanner variable. This will store whatever value the user has typed in. You can use this by placing the scanner right after a print statement so that the user knows when to begin typing. You can add this variable to another variable, do calculations with it, etc


Nesting- refers to placing if statements
inside of other if statements (though nesting can refer to more than just if statements).
Remember, if an if statement's test condition evaluates to true, the block of code (everything between the curly brackets) after it will run top to bottom.
What's inside that block of code can be anything, including more if statements (or loops)!













10. IF Statements
Download the file below to see the powerpoint
​
11. Random numbers
12. Using the "Math" class
Download the file below to see the powerpoint
​
Download the file below to see the powerpoint
​