Test 1 Flashcards
How do you output statements?
System.out.println(“”);
or
System.out.print(“”);
How do you state a variable as a whole number?
int x;
How do you state a variable as a whole number? plus assign a value?
int x = 3;
How do you state a variable as a decimal number?
double x;
How do you state a variable as a decimal number? plus assign a value?
double x = 3.05;
Import the scanner at the start
import java.util.Scanner;
Make a Scanner object
Scanner input = new Scanner(System.in);
Make a Scanner do its stuff (the object is called input) (string is called x)
x = input.next();
What is the Scanner Input.next””(); if Its a Integer or Double
nextInt
nextDouble
What is the difference between == & = ?
== Is a check for truth and false
= Assigning a value to a variable
What is % represent
modulo. its the remainder of a division. Wait…… I can make a long division thing!
8 % 3 =
2
9 % 2 =
1
15284286 % 2 =
0 Because its all even…. except the 5…. it still works out
x = 4;
y = x++;
z = 5 + x;
((y == 5) && (x == 5) && (z <= 10))
T || F
False, y is not equal to 5 but 4
z is 10
x is 5