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

2/4/24, 11:00 PM Ch 3 DEBUG and Flowchart Problems: Attempt review

// This pseudocode is intended to display employee net pay values.

// All employees have a standard $45 deduction from their checks.

// If an employee does not earn enough to cover the deduction,


// an error message is displayed.

start

Declarations

string name

num hours
num rate

num DEDUCTION = 45

string EOFNAME = "ZZZ"

num gross

num net

output "Enter first name or ", EOFNAME, " to quit"

input name

while name not equal to EOFNAME

output "Enter hours worked for ", name


input hours

output "Enter hourly rate for ", name

input rate

gross = hours * rate

net = gross - DEDUCTION

if net > 0 then

output "Net pay for ", name, " is ", net


else

output "Deductions not covered. Net is 0."

endif

output "Enter next name or ", EOFNAME, " to quit"

input name

endwhile

https://moodle.lsua.edu/mod/quiz/review.php?attempt=1518465&cmid=1008399 1/5
2/4/24, 11:00 PM Ch 3 DEBUG and Flowchart Problems: Attempt review

output "End of job"

stop

Question 2
Place these two lines in the code below.
Correct
output "Enter first score or 0 to quit "
1.00 points out input firstTest
of 1.00

Flag question
// This pseudocode is intended to determine whether students have
// passed or failed a course;
student needs to average 60 or
// more on two tests.
start
Declarations
num firstTest
num secondTest
num average
num PASSING = 60
while firstTest not equal to 0
output "Enter first score or 0 to quit "
input firstTest
output "Enter second score"
input secondTest
average = (firstTest + secondTest) / 2
ouput "Average is ", average
if average >= PASSING then
output "Pass"
else
output "Fail"
endif
endwhile
stop

Select one:
a. No changes are necessary.

b. The lines are needed only before the endwhile statement.

c.
The lines are needed before the while statement and before the
endwhile statement.

d. The lines are needed only after the while statement.

e.
https://moodle.lsua.edu/mod/quiz/review.php?attempt=1518465&cmid=1008399 2/5
2/4/24, 11:00 PM Ch 3 DEBUG and Flowchart Problems: Attempt review

The lines are needed only before the while statement.

Question 3 What is wrong with the following flowchart? A is the priming input. B is a selection.
Correct C is the main processing. More than one answer may apply.
1.00 points out
of 1.00

Flag question

Select one or more:


a. Another rectangle with A should follow the No selection of B.

b. Another diamond with B should follow C.

c. The loop back should return below A.

d. Another rectangle with A should follow C.

e. Another rectangle with A should follow the Yes selection of B, but before C.

Question 4
1. Which structure does the following pseudocode represent? loop
Correct

1.00 points out


of 1.00
while testCondition continues to be true
do someProcess
Flag question
endwhile

2. Which structure does the following pseudocode represent? sequence

go north on First Avenue for 3 miles


turn left on Washington Boulevard
do west on Washington for 2 miles
stop at 634 Washington

3. Which structure does the following pseudocode represent? dual alternative

if someCondition is true then


do oneProcess
https://moodle.lsua.edu/mod/quiz/review.php?attempt=1518465&cmid=1008399 3/5
2/4/24, 11:00 PM Ch 3 DEBUG and Flowchart Problems: Attempt review

else
do theOtherProcess
endif

4. Which structure does the following pseudocode represent? single alternative

if employee participates in the dental plan then


deduct $40 from employee gross pay
endif

Question 5
1. This picture depicts a single alternative selection structure.
Correct

1.00 points out


of 1.00

Flag question

2. This picture depicts a sequence structure.

3. This picture depicts a double alternative selection structure.

https://moodle.lsua.edu/mod/quiz/review.php?attempt=1518465&cmid=1008399 4/5
2/4/24, 11:00 PM Ch 3 DEBUG and Flowchart Problems: Attempt review

4. This picture depicts a loop structure.

Question 6

Correct

1.00 points out A selection structure contains a test, and, depending on the result,
of 1.00

Flag question
branches, but does not repeat. An example is when you change lanes going to the

airport based on the signs you see.

In a sequence structure, the tasks are executed one at a time in order, with

no branching or repeating. An example is an exact list of turns to take to drive to


the airport.

A loop structure contains a test, but repeats tasks over and over until

the condition of the test is met. An example is when you circle the airport until your

friend arrives.

https://moodle.lsua.edu/mod/quiz/review.php?attempt=1518465&cmid=1008399 5/5

You might also like