Question

# Chakura is sitting at a table in a bookstore, attending her book signing. Customers are standing...

Chakura is sitting at a table in a bookstore, attending her book signing. Customers are standing in line waiting for her to sign their copy of her book. However, it is possible that some customers in line may not have a book; they are in line simply to meet her. It’s also possible that some customers may have more than one book for her to sign. Write an appropriate algorithm using only the instructions listed in below.

accept the book from the customer

close the book

end repeat

end repeat
open the front cover of the book

place the book on the table repeat while (the customer has a book that needs signing)

repeat while (there are customers in line)

return the book to the customer

sign your name on the first page

thank the customer

Hi,

To implement this, we should know the basic functionality:

• We will only continue as long as there are customers in the queue
• once a customer arrives, note that he may have 0, 1, 2, or many books. So, we will repeat signing the books as long as the customer has a book to sign.
• To sign a book, she need to accept the book, place the book on table, open front page, sign her name, close the book
• Once all of the books belonging to a customer are returned to him , she thank the customer

Here's what the algorigthm will look like:

1. Repeat while(there are customers in line):
• Repeat while(the customer has a book that needs signing):
• accept the book from the customer
• place the book on the table
• open front cover of the book
• .sign your name on the front page
• close the book
• return the book to the customer
end repeat
• thank the customer
end repeat

So what we did is we repeated serving the customers and then thanking them unless there are no customers remaining.
To serve a customer, we repeated signing all the books of a customer.
To sign a book, we accept it, place it on the table, open front page, sign, close the book and return it to the customer.

That's it. I hope this helps!

#### Earn Coins

Coins can be redeemed for fabulous gifts.