Here's an example of a pseudo-code algorithm to buy the textbooks for a class, using
parameters for the course number and section number:
To buy the books for CS 111A Section 001, you would write:
BuyTextBooks(CourseNumber="CS 111A", SectionNumber="001");
To buy the books for English 1A Section 581, you would write:
BuyTextBooks(CourseNumber="ENGL 1A", SectionNumber="581");
Here is the generic algorithm to buy textbooks:
BuyTextBooks(CourseNumber, SectionNumber):
- Go to the college bookstore.
- Pick up a shopping basket.
- Find the section for textbooks.
- Locate the shelf labeled for CourseNumber and SectionNumber.
- Repeat for each required book for this course section:
- Determine the required book's title and author.
- Pick up a copy of the required book and put it in your shopping basket.
- Repeat for each optional book for this course section:
- Determine the optional book's title and author.
- Pick up a copy of the optional book.
- Look at optional book to decide if you want to buy it:
- If you want to buy the optional book:
- Put the optional book in your shopping basket.
- If you do not want to buy the optional book:
- Put the optional book back on the shelf where you found it.
- Go to the cash register.
- Pay for the book(s) in your shopping basket.
- Exit the bookstore with your books.