Java Games: Flashcards, matching, concentration, and word search.

COMP 110 Quiz 3

AB
Flow of controlOrder in which a program performs actions
Branching statementChooses between 2 or more possible actions
Loop statementRepeats an action until a stopping condition occurs
char Type'x' represents a character in char type. Example: char a --> a = 'b' --> System.out.println(a) --> output would be: b
Difference between println() method and print() methodprintln() method advances to a new line after it displays its output. Print() method does NOT advance to a new line. Instead, to make it advance, do this: System.out.print("this is a string\n ");
! (not)Syntax rule: !(expression). Will be TRUE if expression is FALSE. Don't use this because it's confusing! Instead of !(cost == 3) try (cost != 3)
What if you need ONE expression out of MANY to be true?|| (or). Syntax rule: (expression) || (expression), ie. (I've had food) || (time > 7). Will be true if EVEN ONE expression is true.
What if you need multiple expressions to be true?&& (and). Syntax rule: (expression) && (expression), ie. (time < 7) && (I made food). Will only be true if ALL statements are true
Syntax for IF statementif (boolean expression) {statements}
Boolean expressionsCombination of values/variables by comparison operators. Value can only be TRUE/FALSE.
ExpressionsCan be a variable, value, or a combination of made up values, variables and operators
Arithmetic expressionsCombination of numbers with a number value. Ex. 10, taxRate/100, (cost*tax)
String expressionsCombination of strings with a string value. Ex. "Hello," "total cost is" + totalCost
Java comparison operators: Equal toJava notation: ==
Java comparison operators: NOT equal toJava notation: !=
Java comparison operators: Greater thanJava notation: >
Java comparison operators: Greater than or equal toJava notation: >=
Java comparison operators: Less thanJava notation: <
Java comparison operators: Less than or equal toJava notation: <=
if-else statementsProgram checks to see if the if statement in () is T/F. If its TRUE the statement BEFORE the else is executed. If it's FALSE the statement AFTER the else is executed. Ex. if (balance >=0) balance = balance+interest rate; else balance = balance-overdraft



This activity was created by a Quia Web subscriber.
Learn more about Quia
Create your own activities