Variables and Printing
On One Condition(al)
Time for Math Class
Misc. java
More misc. java
200

This is the print statement in Java (either one)

System.out.println() or System.out.print()

200

What is the variable type used for true/false values?

boolean

200

What is PEMDAS an abbreviation for?

parenthesis, exponents, multiplication, addition, and subtraction

200

How can you check if two int or double values are the same?

==

200

How can you check if two String variables are equal?

String1.equals(String2);

400

Have a rational number? Use this variable type that stores decimals!

double

400

This is the expression used to compare two values (non-Strings)

What is == (double equals)?

400

What is the property can be used to solve this problem?

(x+y+z)(a+b+c)

What is distributive property

400

How can you check if two String values are the same?

.equals()

400

What's the difference between scanner.nextLine() and scanner.nextInt();

scanner.nextLine() gets a String value whicle scanner.nextInt() gets an int value

600

What does this code segment do?

i=i+1

adds 1 to i

600

All java data types (that we've gone over):

primitive: int, double, boolean, char, and object: String

600

What is the equation for a linear function? (straight line on graph)

y = mx+b

600

How do you set up a while loop?

while (condition is true) {

      do this;

}

600

How could you use an if statement to check if a int number is even or odd?

if (number<0) {

    System.out.println(number + " is odd");

} else {

    System.out.println(number + " is even");

800

How would you create a variable for the price of chips and set it to $2.50?

double chipPrice = 2.55;

or

double chipPrice;

chipPrice = 2.55;

800

What are the two lines of code that we put before all of our java programs?

public class name {

public static void main (String[] arg) {

}

}

800

What is 24,0310 ?

1

800
How can you check if a number is even/odd in java?


Hint: You typically do this by using a specific operation

Modulo (%) the number by 2. If it returns 0 the number is even, if it returns 1 it's odd.
800

What's wrong with this code? (assume all code before this segment is correct)

1. Scanner myScanner = new Scanner(System.in)

2. String userAnswer;

3. System.out.println("What is your answer?")

4. useranswer = myScanner.nextInt();

- Lines 1 and 3: No ; after the line

- Line 4: useranswer does not match the variable userAnswer

- Line 4: .nextInt() is wrong because userAnswer is a String 

1000

This function from the Java library takes in user input.

java.util.Scanner

1000
In order to have your file compile properly, the name of you .java file needs to match what part of your code?

the class name

1000

Evaluate this expression:

(52+3)-(3-5)2

24

1000

String weather;

weather = scanner.nextLine();

Set up a sequence of if statements to print "yay" if the weather is sunny, ":(" if the weather is rainy, and otherwise print "whatever"

if (weather.equals("sunny")) {

      System.out.println("yay");

} else if (weather.equals("rainy") {

      System.out.println(":(");

} else {

      System.out.println("whatever");

}

1000

What does this code do?


for (int i = 5; i < 0; i--) {

    System.out.println(i);

}

Prints 

5

4

3

2

1