You are on page 1of 2

Connecting with Computer Science Chapter 15 Review:

Chapter Summary:

Java is a high-level language designed for the Internet.

C++ is also a high-level programming language; it is based on the C language but incorporates object-orientated
principles.

Variables are of different data types, including: integer (int), character (char), floating point, Boolean and string.
Assigning a value to a variable is called variable initial- ization or initializing a variable.

Four types of control structures are used in high level programming languages: Selection, Top Down, Invocation,
Repetition.

Java uses methods for the invocation control structure, and C++ uses methods and functions.

Java uses the System.out statement to output data. In C++ the cout statement is used with the << redirect symbols.

The Java Scanner class is used to gather input. In C++, the cin statement is used to gather input.

C++ and Java use the if, if-else, if-else-if and switch statements for selection control structures.

In C++ and Java, the switch statement is used only with scalar variables, such as integers and characters. String
variables cannot be used with the switch statement.

C++ and Java use the for, while and do-while loops for repetition.

To become a good programmer, you must: practice, practice, practice some more.

Code unto others as you would have them code unto you.

Key Terms:
Concatenation (517)
Declaration (513)
Endless Loop (549)
Function (520)
Hungarian Notation (518)
Insertion Point (525)
Nesting (537)
Parameters (521)
Post-conditional Loop (550)
Pre-conditional Loop (548)
Reserved Words (513)
Scope (521)
Variable Initialization (518)

The process of combining or joining strings into one value


A statement that associates an identifier with a variable (or an action or other
programming element)
A block of source that repeats continuously and never stops
A block of code that performs a task and can return a value.
A variable-naming method that adds a letter at the beginning of a variable name
to indicate its data type.
Where the cursor is placed.
Putting one control structure inside another.
A received value assigned to a variable; used by a block of source code.
A loop that executes at least one time before the expression is evaluated.
A loop that checks the expression before any source code in the loop is
executed; might never be executed.
A key word with a specific instructional meaning; the name cannot be used for a
variable because the programming language is already using it as an instruction.
Where source code can be seen and whether other programs can see and use it.
Supplying a value when a variable is first declared.

Test Yourself.
1.) Describe when to use integers variables in Java or C++. Explain the situation, provide a suggested
variable name and support your recommendation.
Integer variables are used for +ve and ve whole numbers. Some examples are: Storing inventory
counts, miles driven, points scored in a sporting event and so on. Variable name for these examples
could be: iCount, iMilesDriven, and iPoints. Placing the i in front of the variable name improves
readability of the source code because a person debugging the program can assume that any
variable starting with i contains an integer value. Here is an example of declaring an integer
variable: int iMilesDriven;
2.) Describe when to use floating-point variables in Java or C++. Explain the situation, provide a suggested
variable name and support your recommendation.

3.) Describe when to use character variables in Java or C++. Explain the situation, provide a suggested
variable name and support your recommendation.
4.) Describe when to use string variables in Java or C++. Explain the situation, provide a suggested
variable name and support your recommendation.
5.) Write a Java or C++ program that displays truth tables for the and (&&) logical operator and the or (||)
logical operator. (Refer to Chapter 14 to review logical operators if needed.)
6.) Write a Java or C++ program that uses the: addition, subtraction, multiplication and modulus
mathematical operators. (Refer to Chapter 14 to review logical operators if needed.)
7.) Write a Java or C++ program that displays five names, using the: for, while, and do-while statements.
8.) Write a Java or C++ program that uses an if-else-if statement to determine your final grade in this
course.
9.) Repeat exercise 8 but with a switch statement.
10.) Describe when you would use: do-while, for and while statements.