U2: Summative Flashcards
1
Q
Counters and Scores
A
Use technique variable = variable + 1 for adding score
2
Q
Variables using Custom Data Types (Classes)
A
- All programs written in Java contain classes
- Examples of custom data types: Strings from String Class, Scanner from Scanner Class
3
Q
Predefined Subprograms
A
- Pre-existing program allowing task to be accomplished quickly
- Ex: Math.round(), Integer.ParseInt()
4
Q
Random Numbers
A
- randomNumber = (int)Math.round(Math.random()*[n-1]+1)
- Generates between 1 and n
5
Q
Creating Random Object
A
- Random random = new Random()
- Written at start of program to allow random values to come
6
Q
Casting a Value to Double
A
- Add (double) at the left of variable
- Ex: int numCorrect; (double) numCorrect
- Can cast to integer, other value as well
7
Q
break (code)
A
Ends a program
8
Q
.equals Subroutine
A
- Used for strings instead of the == sign
- Ex: if (variable1.equals (variable2))