Comp Sci 7.8-11

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

18. How many times will this program statement display "HELLO WORLD" ? for (int p = 1; p <= 10; p++) { for (int q = 1; q <= 7; q++) { System.out.println("HELLO WORLD"); } }

70

17. In computer science, what is a flag?

A flag is a special value that makes the loop stop.

Look at program LoopingWithGraphics03.java and its output. Why are these diagonal lines parallel?

Because the x values increase by the same increment and y values increase by the same increment

11. Besides int and double, what other data type can be used as a for loop counter?

Char can also be used.

3. In fixed repetition, what does fixed mean?

Fixed means that ahead of time you know how many times a segment will repeat.

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

It uses the while loop, a conditional loop.

4. What does LCV stand for?

Loop Control Variable- the counter

1. What are 2 synonyms for Repetition?

Looping and iteration

Because of this, while is called a ___________ loop and do...while is called a ___________ loop.

Precondition, post condition

21. How is the do...while loop similar to the while loop?

The do while loop is another conditional loop structure.

14. The for loop has 3 things between the parentheses in the heading. List them.

The for loop has the initialization of the Loop Control Variable. Part 2 sets the exit condition for the loop. Part 3 determines how the LCV changes.

Imagine you change both of the 10s in this program to 5s. How will the output of this new program be different?

The lines would be closer together.

29. Imagine you change both of the 10s in this program to 20s. How will the output of this new program be different?

The lines would be spaced farther apart.

Use this statement for questions 5-10: for(j = 1; j <= 100; j++) 5. What does the j = 1 mean?

The program beings to count with 1

Use this statement for questions 5-10: for(j = 1; j <= 100; j++) 6. What does the j <= 100 mean?

The program will be true and execute as long as the counter is under or equal to 100.

What is the only thing between the parentheses in the heading of a while loop.

The while loop only has the loop entry condition in the heading so only the Loop Control Variable is initialized.

30. Why are all of the lines horizontal?

The x value increase but the y values stay the same.

28. Why are all of the lines vertical?

The y values decrease and the x values stay the same.

If the while loop only has 1 of these 3 things in its heading, where do the other 2 go?

They go inside the loop.

27. In its simplest terms, what is this statement checking for? if (number % 2 == 0)

Whether or not the number is even.

22. How is the do...while loop different from the while loop?

While (precondition loop) checks the condition at the beginning, but do while checks the condition at the end (post condition loop).

Why is the financial aid if...else nested inside the admittance if...else?

You would not need financial aid if you were not admitted.

19. With nested loops, the inner loop must complete its repetitions __________ the outer loop can increase its LCV value.

before

Use this statement for questions 5-10: for(j = 1; j <= 100; j++) 9. Rewrite the for loop heading so it counts from 0.25 to 2.75 by 0.25.

for (j= 0.25; j<=2.75; j+= 0.25)

Use this statement for questions 5-10: for(j = 1; j <= 100; j++) 10. Rewrite the for loop heading so it counts from 100 backwards down to 1, by 1s.

for (j= 100; j>= 1; j--)

Use this statement for questions 5-10: for(j = 1; j <= 100; j++) 8. Rewrite the for loop heading so it counts from 0 to 100 by 2.

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

2. What loop structure is used with fixed repetition?

for loop structure

24. Assume the while loop's condition is false before the loop even starts. How many times will the while loop execute?

none

25. Assume the do...while loop's condition is false before the loop even starts. How many times will the do...while loop execute?

once

Use this statement for questions 5-10: for(j = 1; j <= 100; j++) 7. What does the j++ mean?

the counter goes by ones


Ensembles d'études connexes

Fluid and Electrolytes (Fluid volume deficit)

View Set

Quiz Block 4: PUNCTUATION/MECHANICS: Commas I, paragraph editing

View Set

Environmental earth science final

View Set

Hesi Final Study Questions: Med Surg II

View Set

Chapter 23: Gynecologic Emergencies

View Set

Using Equations and Powers of Numbers - L3

View Set