Chapter 1 sec. 1-2 Flashcards

computer program basics

1
Q

Input?

A

data from peripherals, network, file..

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Process?

A

computations on data such as adding x + y

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Output?

A

after computations with data, data is put somewhere like a file or screen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Variables?

A

Data is held with a placeholder “variable” similar to algebra with X or Y. Each variable is a value or holds a rule

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

in programming z = x + y means what? is this the same as math?

A

z = x + Y means it is an assignment: Z is assigned with the sum of X and Y.. in math Z would be equal to what Z and Y are.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the definition of an Algorithm?

A

algorithm: sequence of instructions that solve a problem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what word and what symbols are used to start a program ?

A

Main ( ). statements are executed within main’s () using their own braces { } one at a time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what symbols are used within a program ( ) to “house/ hold” the statements that are executed and starts the code to be executed?

A

{ } are used to execute statements that are inside a program ( ). so main ( ) is used 1st to start the executable code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

instead of a period, what is used to end a statement within a program?

A

a semicolon ;

The } symbol is only used at the end of all the statements within a program on a line below.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

are statements within a program, grouped together or does each get its own line?

A

each statement gets its own line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

how is a variable created? use integer as an example

A

int Wage
wage is the name of the variable (this is where the variable gets named)
the int tells the program that the word wage represents an integer, aka a number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

using the text below. how would these statements be written in code?
integer = wage
wage = 20

A

{
int wage;
wage= 20;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what word/ symbol is used in the code to tell it to start executing the code that follows?

A

main ( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how does a program get input for its executable code?

A

a scanner is used. to create a scanner object.

scanner is a word used in the program to tell it where to get the input from, such as a keyboard

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is a scanner object in code? how is it written?

A
a scanner object is a placeholder that is represented by an assigned input.
     written as:
scanner scnr = new scanner(system.in);
     scnr is the object that contains an input device which in this case is a keyboard because system.in is what refers to keyboard in code.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is a scanner and what is a variable?

A

scanner = where the program gets its input (keyboard, etc)
variable = a number.
both scanner and variable are used to initiate specifying a custom object that represents a number or an input location.

17
Q

what does this text do?

system.out.print “ “

A

this command causes whatever is in “ “ afterwards to print to the screen as output.

18
Q

what is a string lateral?

A

string lateral
“ “
any text that is contained within quotes.

19
Q

if a series of commands using system.out.print with string lateral afterwards “ “ and the words all print on one line.. why is this? what should be done?

A

system.out.print
construct does support output but when multiple statements are used, even when on their own lines in the code and seporated by ; they will print on the same line.
**the following construct command should be used instead because it causes a new line to be printed on for each construct command.
system.out.printiln
the lowercase L n stands for newline and tells the program to go to the next line for following commands.

20
Q

are paranthesis always reqwuired around a string literal “ “ ?

A

yes. for text to print then the string literal needs “ “ surrounded by ( )

21
Q

what code should be used to type the following sentence on the same line and have it print on the screen?
Hello World!

A

System.out.print(“Hello World!”) ;

22
Q

what is used to print the output of a variable’s value? what is the code?

A

System.out.print(wage) ;
“ “ are not used because the variable wage, is a number and not a literal string or word. We can also use ln at the end of the command if we need new lines to be printed

23
Q

what code is used to print the results of several variables with different lines, but in a compact way? is there a shortcut to using system.out.print for each item you want printed?

A

shortcut or way to combine output statements:
use the plus symbol + between variables to condense the code and make easier to read.
example:
System.out.put(“the number of people is =” + AnObjectLikeWAGE);
what will be printed:
the number of people is = wage (aka a number)

24
Q

output statement?

A

a line of code that is used to print something to the screen or put out output.