Dale - Computer Science Illuminated 259

Dale - Computer Science Illuminated 259 - is how...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
232 Chapter 8 High-Level Programming Languages Boolean Expressions In Chapter 6, we wrote an algorithm to create an address list that includes each person’s name, address, telephone number, and e-mail address. One of the subalgorithms was to fill in missing data that had not been entered originally. Let’s look at this module. There is one loop and three selection statements in this algorithm. We continue looping while there are more names. If a street, telephone number, or e-mail address is missing, the algorithm asks for this informa- tion. Notice how these questions are phrased: (there are more names) (street is missing) (telephone is missing) (eMail is missing) Each phrase is actually a statement. If the statement is true, the answer to the question is true. If the statement is not true, the answer to the question is false. Making statements and then testing to see if they are true or false
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: is how programming languages ask questions. These statements are called assertions or conditions . When we are writing algorithms, we make asser-tions in English-like statements. When the algorithms are translated into a high-level programming language, the English-like statements are rewritten as Boolean expressions. Fill in missing data Level 1 Write “To any of the prompts below, if the information is still not known, just press return.” Get a name from the list While (there are more names) Get a lastFirst Write lastFirst If (street is missing) Write “Enter street number and name; press return.” Read street If (telephone is missing) Write “Enter area code and 7-digit number; press return.” Read telephone If (e-Mail is missing) Write “Enter e-mail; press return.” Get a name from the list...
View Full Document

This note was uploaded on 01/13/2011 for the course CSE 1550 taught by Professor Marianakant during the Fall '10 term at York University.

Ask a homework question - tutors are online