• Home
  • Textbooks
  • Introduction to Programming with Java: A Problem Solving Approach
  • Algorithms and Design

Introduction to Programming with Java: A Problem Solving Approach

John S. Dean, Raymond H. Dean

Chapter 2

Algorithms and Design - all with Video Answers

Educators


Chapter Questions

00:14

Problem 1

Describe what this statement does:
print "user name $="$ userName

Amy Jiang
Amy Jiang
Numerade Educator
00:20

Problem 2

Provide an appropriate variable name for a variable that holds the total number of students.

Harsh Gadhiya
Harsh Gadhiya
Numerade Educator
01:40

Problem 3

Write a line of pseudocode that tells the computer to assign distance divided by time into a speed variable.

Grant Castaneda
Grant Castaneda
Numerade Educator
01:40

Problem 4

Write a line of pseudocode that tells the computer to put a user entry into a variable called height.

Banhishikha Sinha
Banhishikha Sinha
Numerade Educator
00:40

Problem 5

What are the three types of control flow described in this chapter?

Sydney Atkins
Sydney Atkins
Numerade Educator
02:12

Problem 6

Looping is appropriate whenever the next thing done is something previously done. (T / F)

Ernest Castorena
Ernest Castorena
Numerade Educator
01:06

Problem 7

Consider the following pseudocode:
if it is night, set speedLimit to 55;
otherwise, set speedLimit to 65.
Suppose the value of the variable, night, is “false.” After this code runs, what should be the value of the
variable, speedLimit?

SC
Shonte Cobbs
Numerade Educator
04:16

Problem 8

The above pseudocode does not have the exact form suggested in the text. Is that OK?

Shalini Tyagi
Shalini Tyagi
Numerade Educator
03:37

Problem 9

Draw a flowchart that implements this logic: If the temperature is greater than $10^{\circ} \mathrm{C}$ and it's not raining, print "walk." Otherwise, print "drive."

WM
William Mead
Numerade Educator
03:56

Problem 10

Provide a solution to the previous problem in the form of pseudocode.

Bryan Lynn
Bryan Lynn
Numerade Educator
01:00

Problem 11

Where is a while loop's terminating decision made?

Vysakh M
Vysakh M
Numerade Educator
02:20

Problem 12

When a while loop terminates, what executes next?

Ernest Castorena
Ernest Castorena
Numerade Educator
02:11

Problem 13

Is it possible for a while loop to have an infinite number of iterations?

Uma Kumari
Uma Kumari
Numerade Educator
00:56

Problem 14

Is it possible for a while loop to have zero iterations?

Linh Vu
Linh Vu
Numerade Educator
00:40

Problem 15

What are the three loop termination techniques described in this chapter?

Sydney Atkins
Sydney Atkins
Numerade Educator
01:15

Problem 16

A sentinel value is used to do which of the following?
a) Specify the first value printed.
b) Print an error message.
c) Signal the end of input.

Zack Spears
Zack Spears
Numerade Educator
03:56

Problem 17

How does the form of pseudocode we use in most of this chapter differentiate an inner loop from an outer loop?

Bryan Lynn
Bryan Lynn
Numerade Educator
01:02

Problem 18

Which of the following is true?
a) Tracing shows sequence of execution.
b) Tracing helps you debug a program.
c) Tracing highlights errors in loop initialization and termination.
d) All of the above.

Benjamin Schreyer
Benjamin Schreyer
Numerade Educator
02:23

Problem 19

Trace the following Bowling Score algorithm (taken from Section 2.9). Use the setup shown below the algorithm.
1 set totalscore to 0
2 set count to 0
3 print "Enter score $(-1 \text { to quit): } "$
4 input score
5 while score is not equal to -1
6 set totalscore to totalscore + score
7 set count to count +1
$8 \quad$ print "Enter score $(-1$ to quit): "
9 input score
10 set avg to totalscore / count
11 print "Average score is " avg
Trace setup:
input
94
104
114
1

Ajay Singhal
Ajay Singhal
Numerade Educator