(1) / This pseudocode segment is intended to describe
/ computing the price of an item on sale for 20% of
start
input origPrice
set discount = origPrice * 0.20
set finalPrice = origPrice - discount
output finalPrice
stop
Test Cases:
origPrice
100
20
60
fi
Chapter 3: Exercise 2 and 3
A)
do A
while B is true
do C
do A
endwhile
B)
do D
if E is true then
do H
do I
else
do F
if G is true then
do I
endif
endif
C)
do k
if L is true then
do P
while Q is true
do P
endwhile
do R
else
do M
do N
if 0 is true then
do R
(1)
/ This pseudocode segment is intended to determine whether students have
/ passed or failed a course based on the average score of two
/ tests. Student needs 60 average or better to pass.
start
Declarations
num firstTest
num secondTest
num average
num
1)
/ This pseudocode segment is intended to compute and display
/ the average grade of three tests (format average to two decimal places).
/Programmed by
start
Declarations
num test1
num test2
num test3
num average
output "Enter score for test 1 "
input t
1)
/ This pseudocode should create a report that contains a
/ rental agent's commission at an apartment complex. The
/ program accepts the ID number and name of the agent who
/ rented the apartment, and the number of bedrooms in the
/ apartment. The commi
Exercise 4: Exercise 4-6
/This program is intended to accept a number, divide it by two and output the result.
/Programmed by
start
input myNumber
set outputNumber = myNumber / 2
output outputNumber
stop
Test Cases:
myNumber
50
100
666
outputNumber
25
50
Exercise Chapter 5- Part B
B.
/ runs continuously for any number of cars while the sale price is not 0; calculate profit, prompts
next /sale price.
/Programmed by
start
declarations
num carPurchasePrice = 0
num carSalePrice = 0
num profit = 0
housekeeping
start
Declarations
num guessNumber = 0
num correctNumber = 0
string guessLow = Number is too low, input higher guess
string guessHigh = Number is too high, input lower guess
string guessCorrect = You win!
correctNumber = random(100)
output Guess a number
Chapter 4 Exercise 4
/This pseudocode calculates the customers basic rate of $5 per month to send text messages
/The first 60 message per month, regardless of message length, are included in the basic bill
/An additional five cents is charged for each tex
(1) / This pseudocode segment is intended to describe
/ computing the price of an item on sale for 20% of
start
input origPrice
set discount = origPrice * 0.20
set finalPrice = origPrice - discount
output finalPrice
stop
Test Cases:
origPrice
100
20
60
fi
/ This pseudocode segment is intended to determine whether students have
/ passed or failed a course based on the average score of two
/ tests. Student needs 60 average or better to pass.
start
Declarations
num firstTest = 0
num secondTest = 0
num average
Example A:
do A
while B is yes
do C
do A
endwhile
Example B:
do D
if E is yes
do H
do I
else
do F
if G is yes
do I
endif
endif
Example C:
do K
if L is yes
do P
while Q is yes
do P
endwhile
do R
else
do M
do N
if O is yes
do R
endif
endif
Example D:
do S
i
Exercise 7a
/This program is intended to calculate the area of floor by multiplying the values of two numbers
/Programmed by
start
input lengthOfFloor
input widthOfFloor
set areaOfFloor = lengthOfFloor * widthOfFloor
output areaOfFloor
stop
Test Cases:
le