Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Connecting with Computer Science Chapter 14 Review:

Chapter Summary:

A program is only as good as the programmer who wrote it.


Programs are used everywhere and in almost everything you do.
A program can be interpreted and compiled.
Low-Level languages are most closely related to the machine language a computer understands.
Assembly language is a low-level programming language.
High-level languages are more closely related to human language.
Algorithms are created to solve problems with a logical method.
Programmers use pseudo code to map out how a program is suppose to work.
Creating an algorithm is one of the most important steps in writing a program.
Variables are temporary storage locations and are used in programs for performing calculations and
storing information.
Programming languages use mathematical, relational and logical operators.
Four types of control structures are used in a program: top down, invocation, selection, and repetition.
(OOP) allows programmers to reuse code and makes programs easier to maintain.
(OOP) creates classes, which are like templates ar molds for creating objects.
Objects can have properties, methods and event handlers.
Java follows the OOP model closely.
To become a good programmer, you must practice, practice and practice some more.

Key Terms:
Algorithm (468)
Assembler (473)
Assembly Language (473)
Base Class (500)
Class (498)
Compiler (468)

Constructor (498)
Control Structure (492)

Encapsulation (501)
Event (498)
Event Handler (498)

A logically ordered set of statements used to solve a problem.


A program that reads assembly language code and converts it into machine
language.
A programming language that is 1 step up from machine language it assigns
letter codes each machine-language instruction.
A general class from which other classes can be created via inheritance.
A template for defining new object types and their properties (characteristics or
attributes) and behaviors
An application that reads all the programs statements and converts them into a
computer language and produces and executable file that does not need an
interpreter.
A special method for instantiating an object
An instruction that dictates the order in which statements in a program are
executed.

The process of hiding an objects operations from other objects.


An action or occurrence reorganized by a class.
How a class responds to an event.

Expression (498)

A statement containing a combination of values that is interpreted and


computed to produce another value.
High-level Language (473) A programming language written in a more natural language that humans
can read and understand.
Identifier (486)
Name of a variable.
Inheritance (499)
The process of creating more specific classes based on generic classes.
Instantiation (498)
The process of creating an object based on a class and assigning memory
to it.
IDE (478)

Interpreter (486)
Low-level language (473)
Machine language (473)
Method (498)
Object (498)
OOP (495)
Operators (487)
Polymorphism (501)
Precedence (491)
Program (468)
Property or attributes (498)
Pseudo code (479)
Sub classes (500)
Syntax (475)
Variable (485)

An interface provided with software development languages that incorporates


all the tools needed to write, compile and distribute programs; these tools
often include an editor, a compiler a graphical designer and more.
An application that converts each program statement into a language the
computer understands.
A programming language that uses binary code for instructions.
The lowest-level programming language, which consists of binary bit patterns.
The work performed by an object; a function defined in a class
A self-contained entity consisting of both data and procedures.
A style of programming that involves representing items, things, and people as
objects instead of basing program logic on actions.
Symbols used to indicate data-manipulation operators.
An objects capability to use the same expression to denote different
operations.
The order in which something is executed; symbols with a higher precedence
are executed before those with a lower precedence.
A collection of statements or steps that solves a problem and needs to be
converted into a language the computer understands to perform tasks.
Characteristics of an object.
A readable description of an algorithm written in human language.
A more specific class based on a parent class and created via inheritance.
Rules for how a programming languages statements must be constructed.
A name used to identify a certain location and value in the computers memory.

Test Yourself:
1.) What is an algorithm?
A logically ordered set of statements used to solve a problem.
2.) Write an algorithm for calculating your cheque book balance.
If the amount is to be deposited, add it to the current balance. If the amount is to be withdrawn,
subtract it from the current balance.

3.) Pseudo code for calculating your chequebook balance:

Ask for the current balance of the chequing account.


Ask if deposit or withdrawal (cheque written)
Ask for amount.
Ask for date.
If deposit.
Current balance = Current balance + amount
ELSE IF withdrawal (cheque written)
Current balance = Current balance amount
Store information.
4.) When the gas pump lever is lifted up and the gas grade is selected, reset the dollar amount and the
amount of gas pumped and display the price per gallon. When the pump handle lever is lifted, begin
pumping gas and updating the display areas showing the dollar amount and amount of gas pumped.
Continue pumping gas until the sensor clicks off the gas pump handle or until the user releases the
handle. Turn off the pump when the gas lever is pushed down.
5.) Pseudocode for maintaining a gas pumps operation.
System is idle.
Continue checking to see if gas lever is lifted.
While gas lever is lifted
If gas grade selected = Unleaded
Begin pumping unleaded gas
Else if gas grade selected = Premium
Begin pumping premium gas
Update gas pump display area
End while
Put system back in idle state
8.)

Pseudo code for tic-tac-toe game


Declare a 2 x 2 array of char (or string)
LOOP: Stay in this loop until the game is won or all positions have been used and there is no winner
Prompt for an X or an O
Store response in a variable
Prompt for a row
Prompt for a column
Check to see whether the location is available
If not, prompt that the position has already been used and go back to the LOOP
Else store the variable's content in the array position using the row and column
See whether the player has "tic-tac-toe" by evaluating the array's contents
If a player wins, display a prompt and set a value to terminate the loop
Else allow the loop to return back to LOOP

9.) Pseudo code for getting to school.


Turn off alarm
Get out of bed
Shower and take care of bathroom necessities (BRUSH YOUR TEETH)
Eat breakfast
Grab books and keys
Get in car
Drive to school
Park car
Run to class to avoid being late
10.)

Pseudo code for 3 x 3 sudoku puzzles

Select the available cell in the grid


If there is no available cells, display a message that the sudoku is filled out and exit the loop
Select the lowest number for the cell (1 through 9)
Check that number is used in the row, the column, or the 3x3 cell
Repeat until you find an available number
If there is no available number, display a message that the sudoku cannot be completed and exit the
Loop.
After you find an available number, store it in the cell
Repeat until there are no available cells
Add up all values in each row and see if the sum is 45
If not, display an error message and exit the loop
Add up all values in each columns and see if the sum is 45
If not, display an error message and exit the loop
Display a message that the sudoku is completed

Practise Exercises:
1.) Which is not an example of a high-level programming language?
Boolean
2.) Which of the following converts source code into a computer language and results in an executable
file?
Compiler
3.) Which of the following translates a program's statements, one by one into a language a computer can
understand?
Interpreter
4.) Pseudocode should be written after source code to ensure that the program was written correctly.
False
5.) Which is not a type of programming language?

None of the above

6.) The only language computers can understand consists of 1s and 0s.

True

7.) All languages include an IDE

False

8.) What is a name used to identify a specific location and value in memory?

Variable

9.) What is the final result of the expression 5 + 2 * 4 - 2?

11

10.) What is the final result of the expression 5 % 4 + 3 - 2?


2
11.) The postincrement operator increments the variable and then processes the remainder of the
statement.
False
12.) The preincrement operator increments the variable and then processes the remainder of the
Statement.
True
13.) Which is not a type of control structure?
Algorithm [STIR]

You might also like