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