Computer Programming Unit 5

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What kind of operator is "="?

"=" is an assignment operator.

What would be the output of program Java0513 if B was entered? Enter letter grade =>b

80...89 average 70...79 average 60...69 average Below 60 average

What is a conditional statement?

A conditional statement is a program expression, which evaluates to true or false.

What kind of operator is required to make an expression evaluate to true or false?

A relational operator is required to make an expression evaluate to true or false.

All conditions must be placed inside what?

All conditions must be placed inside parentheses.

Give a real-life example of Two-Way Selection.

An example of a two way selection would to eat a slice of pizza of a bowl of salad.

Selection control structures use a special _____________ statement

Conditional

What does the j <= 100 mean?

Continue to execute the loop as long as this statement is true.

What would you need to change in program Java0515 if Joe wanted the message displayed 1000 times?

Copy the output line 960 more times

What statement is used with if for two-way selection?

Else

What would be the output of program Java0512 if B was entered

Enter letter grade =>b 80...89 average

In fixed repetition, what does fixed mean?

Fixed means that the number of times that a program segment repeats,

What loop structure is used with fixed repetition

For

Refer to your answers to the previous question.What parameter do all of these methods need?

For GUI input, the prompt is a parameter for the GUI input method

What does GUI stand for?

Graphical User Interface

Write the Java statement that will do this action: If your grade is 70 or better, print "You passed!" otherwise print "You failed!"

If (grade>=70) System.out.println("You passed"); Else System.out.println("You failed");

Write the Java statement that will do this action: If your grade is 70 or better, print "You passed!"

If(grade>=70) System.out.println("You passed");

What does the j++ mean?

Increment the loop control variable by one for each iteration

Look at program Java0503.java. This program gives the impression that it will find the sum of 2 entered numbers. Why does it not work?

It doesn't work because when we used the plus (+) operator to "add" the strings, we did not get addition at all. We got String Concatenation. It simply joined the two number strings together

What does the j = 1 mean?

It is the loop control variable

Look at program Java0521. How does this program cure the problem of the previous program?

It uses a while loop instead of a for loop

While program Java0511 compiles and executes, its output is strange. How does program Java0512 fix the problem?

It uses the break keyword

What are 2 synonyms for Repetition

Iteration and looping

List the 6 relational operators.

Java has six relational operators: equals, not equals, greater than, less than, greater than or equal, and less than or equal.

What does LCV stand for?

Loop Control Variable

Most conditional statements will require what?

Most conditional statements require a relational operator.

Explain Multiple-Way Selection.

Multiple selection is a commonly used control structure that simulates many situations in real life. The program flow encounters a group of conditions, one after the other.

What kind of loop is the while loop?

Precondition

Look at program Java0504.java. How does this program cure the problem of the previous one?

Program Java0504.java, in figure 5.4, makes a small, but very significant change to enterInt. Now you can enter intergers.

What does program flow follow?

Program flow follows the exact sequence of listed program statements, unless directed otherwise by a Java control structure.

In what computer language do programs require control structures?

Programs require control structures in any computer language.

Explain Repetition.

Repetition is a repeating structure.

What are 2 synonyms for Selection?

Selection is also called conditional or decision making.

How does Simple Sequence work?

Simple sequence is a program statement after a program statement. It's a series of program statements that are executed in the exact sequence that they are written.

In computer science, what is a flag?

The flag is the special value that makes the loop stop

Look at program Java0509. Why does this program have strange output?

The if statement only controls the line immediately following it.

What statement is used with if for two-way selection?

The if statement only controls the line immediately following it. Does have brackets {} in the code

The for loop has 3 things between the parentheses in the heading. What is the only thing between the parentheses in the heading of a while loop

The loop condition

Why is the do...while loop called a post condition loop

The loop condition comes after the loop body

What are the 3 general types of control structures?

The three general types of control structures are simple sequence, selection, and repetition.

In one-way selection, when does the program flow branch off?

The value of the condition determines if the program flow will "branch off" from the main program sequence

What Expo class method would you use to enter someone's name?

There are special inputting methods in the Expo class which you can use to enter someone's name.

What are the 3 types of Selection?

Three types of selection are one way selection, two way selection, and multiple way selection.

14. What is the essence of understanding, and using, control structures?

Understanding conditional statements is the essence of understanding and using, control structure.

How do you control multiple statements with two-way selection?

Use braces

How do you repeat multiple statements with the for loop structure?

Use braces

What Expo class methods will let you use GUI windows to enter strings, integers, characters, and real numbers?

We can enter integers, real numbers, characters, and strings on a text window

Java does not use "=" to test for equality?

What does it use instead? Java uses (==) to test for equality.

When is the default statement executed

When something is entered that is not a choice

Why is a prompt necessary for program input?

Without a prompt, the user would just see the cursor flashing on the screen and have no idea what to enter

Look at program Java0520. The program's output is very strange. What caused this?

Wrong type of loop was used

What company invented the GUI?

Xerox invented the GUI.

Must the loop counter in a for statement be an int?

Yes

What Expo class methods will let display output in a GUI window?

displayGUI method that will display data in a GUI widnow.

What Expo class method is used to enter a single letter or character

enterChar commamd.

What Expo class method is used to enter real number information

enterDouble command

Refer to your answer to the previous question. Give an example of where this command would be useful.

entering someone's middle initial.

What would you need to change in program Java0516 if Joe wanted the message displayed 1000 times?

for (k = 1; k <= 1000; k++)

for( int j = 1; j <= 100; j++) Rewrite it so it counts from 100 backwards down to 1, by 1s

for( int j = 1; j <= 100; j++)

Why should indentation be used with control structures?

helps to identify the program statement or statements that will only be executed if the condition is true

What does the nextLine method do?

nextLine enters strings

***What is the simplest control structure

one-way selection

13. What do Selection and Repetition control structures have in common?

selection and repetition control structures

In one-way selection, what happens if the condition is false?

the program flow continues without change in program sequence


Kaugnay na mga set ng pag-aaral

History Final Past Material (Quizzes 4 & 5)

View Set

Chapter 47: Caring for Clients with Disorders of the Liver, Gallbladder, or Pancreas

View Set

AH 3320: Epidemiology and Public Health

View Set

Reproductive System Final Review

View Set

Signal Transduction I: Ion Channel-Linked Receptors and G-Protein Coupled Receptors

View Set