11. Study the algorithm shown in Figure 1-14 and then answer the questions. repe
ID: 3885224 • Letter: 1
Question
11. Study the algorithm shown in Figure 1-14 and then answer the questions. repeat 5 times: get the salesperson's name and sales amount calculate the bonus amount by multiplying the sales amount by 3% print the salesperson's name and bonns amount end repeat Figure 1-14 Algorithm for Exercise 11 Cengage Learning 2013 a. Which control structures are used in the algorithm? b. What will the algorithm print when the user enters Jake Harrington and 5500 as the salesperson's name and sales amount, respectively? c. How would you modify the algorithm to also print the salesperson's sales amount? salespeople? e. How would you modify the algorithm to allow the user to enter the bonus rate? The algorithm should then use that rate to calculate the bonus amount.Explanation / Answer
a) Since program repeat for 5 times , hence its WHILE LOOP control structure
b)
get the salesperson's name and sales amount
Above pseudo code prompt user to enters Jake Harrington and 5500 as salesperson name and sales amount.
calculate the bonus amount by multiplying the sale amount by 3%
Above pseudo code calculates the bonus amount by multiplying the sales amount by 3%
So, bonus amount = 5500*3/100 = 165
print the salesperson's name and bonus amount
Above pseudo code prints the sales person name and bonus amount.
Hence it prints following :
Jake Harrington 165
c)
repeat 5 times:
get the salesperson's name and sales amount
calculate the bonus amount by multiplying the sale amount by 3%
print the salesperson's name, bonus amount and sales amount
end repeat
d) For any number of users, we can repeat n times where n is number of sales people
repeat n times:
get the salesperson's name and sales amount
calculate the bonus amount by multiplying the sales amount by 3%
print the salesperson's name and bonus amount
end repeat
e) Here instead of multiplying directly with %, we will multiple by bonus rate enterd by user
repeat 5 times:
get the salesperson's name , sales amount amd bonus rate
calculate the bonus amount by multiplying the sales amount to bonus rate
print the salesperson's name and bonus amount
end repeat
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.