What Does Trace the code mean
going line by line to recheck your code
What does a loop usually do
prints out what you want more than once
What does an if and else statement do?
if (x = 5) {
System.out.println("x is 5");
} else {
System.out.println("x is not 5");
}
the else cannot have a condition
What is a variable in Java
A variable is used as a sort of storage
where is it best to start when tracing code
from the top going down
What types of loops, loops only when a condition is met
a while loop
When is a if and else statement usually used
When you want multiple outcomes that can appear depending on the inputs
int score = 85;
if (score >= 90) {
System.out.println("A");
}
else if (score >= 80) {
System.out.println("B");
}
else (score >= 70) {
System.out.println("C");
}
only the if and else can have a condition and else cannot
What is the purpose of an if statement in Java?
An if statement is used to make decisions in a program. It runs a block of code only if a certain condition is true.
Why is it good to trace the code
it allows you to check for any mistakes you made early on
what are the two types of loops
while loop and forloop
When should an if and else statement be checked
After the values were checked
int age = 16;
if (age > 18) {
System.out.println("Adult");
}
if (age > 13) {
System.out.println("Teen");
}
else {
System.out.println("Child");
}
The else went with the wrong if
What does System.out.println() do in a Java program?
System.out.println() prints text or values to the screen