Chapter 14: Boolean Expressions Bradley Kjell (Revised 10/08/08)


 Lorin Newman
 5 years ago
 Views:
Transcription
1 Chapter 14: Boolean Expressions Bradley Kjell (Revised 10/08/08) The if statements of the previous chapters ask simple questions such as count<10. Often simple questions are not enough. This chapter discusses ways to ask more complicated questions. Chapter Topics: Relational Operators (review) Logical Operators AND Operator How to check that a number is in range Boolean Expressions OR Operator Comparison between AND and OR NOT Operator Questions involving boolean expressions have been prominent on past AP Computer Science Tests. QUESTION 1: You have decided to bake some cookies (much cheaper than buying them at the Mall). An interesting cookie recipe calls for 4 cups of flour and 2 cups of sugar. You look in your pantry and find 3 cups of flour and 2 cups of sugar. Can you bake cookies with what you have? Used by permission. Page 1 of 29
2 No. You have enough sugar, but not enough flour, so you can't follow the recipe. Both Items Needed The question about whether you have enough ingredients has two parts: You need at least 4 cups of flour AND You need at least 2 cups of sugar Since you do not have enough flour, you don't have enough ingredients. QUESTION 2: What if you had 9 cups of flour and 1 cup of sugar. Now could you follow the recipe? Used by permission. Page 2 of 29
3 No. You need 4 cups of flour and 2 cups of sugar. Now you have more than enough flour, but not enough sugar, so you can't follow the recipe. Cookie Calculator In order to bake cookies two things must be : You must have 4 or more cups of flour. You must have 2 or more cups of sugar. If just one of these is false, then you do not have enough ingredients. Here is a simulation of the cookie program. Enter some values for sugar and flour and see if you can bake cookies. Use only integers as input. The symbol && means AND. The if statement asks a question with two parts: if ( flour >= 4 && sugar >= 2 ) flour part sugar part Each part is a relational expression. A relational expression uses a relational operator to compute a or false value. The entire expression between parentheses is also a boolean expression. A boolean expression is often composed of smaller boolean expressions. This is similar to human language where compound sentences are made from smaller sentences. QUESTION 3: Say that you enter 9 for flour and 1 for sugar. What value ( or false) does each part give you? Used by permission. Page 3 of 29
4 flour >= 4 sugar >= 2 false Examine this part of the program: && // check that there is enough of both ingredients if ( flour >= 4 && sugar >= 2 ) System.out.println("Enough for cookies!" ); else System.out.println("sorry..." ); For you to have enough ingredients, both relational expressions must be. This is the role of the && (andoperator) between the two relational expressions. The && requires that both flour >= 4 and sugar >= 2 are before the entire expression is. The entire question must be in order for the branch to execute. The and operator && is a logical operator. A logical operator examines two /false values and outputs a single /false value. QUESTION 4: What is printed if the user enters 6 for flour and 4 for sugar? Used by permission. Page 4 of 29
5 How much flour do you have? 6 How much sugar do you have? 4 Enough for cookies! When execution gets to the if statement, it finds that flour >= 4 is, because 6 >= 4 and sugar >= 2 is, because 4 >= 2 Both sides are, so AND gives. AND Operator The and operator requires that both sides are : this side must be && this side must be If both sides are, the entire expression is. If either side (or both) are false, the entire expression is false. && is a logical operator because it combines two /false values into a single /false value. Here is what && does: && = false && = false && false = false false && false = false Use and when every requirement must be met. QUESTION 5: Look at the boolean expression: flour >= 4 && sugar >= 2 What will the expression give us if flour is 2 and sugar is 0? Used by permission. Page 5 of 29
6 The whole expression will be false, because && combines two falses into false. flour >= 4 && sugar >= false && false false Cookie Program In fact, as soon as the first false is detected, you know that the entire expression must be false, because false AND anything is false. flour >= 4 && sugar >= false && does not matter false As an optimization, Java only evaluates an expression as far as needed to determine the value of the entire expression. When program runs, as soon as flour >= 4 is found to be false, the entire expression is known to be false, and the false branch of the if statement is taken. This type of optimization is called shortcircuit evaluation. (See the chapter on this topic.) Here is a full Java version of the cookie program. Used by permission. Page 6 of 29
7 Try the program with various values of flour and sugar to check that you understand how AND works. QUESTION 6: Try the program with exactly enough flour and sugar. Can you bake cookies? Used by permission. Page 7 of 29
8 Yes. It is always good to test programs with values that are right at the limit. Car Rental Problem A car rental agency wants a program to determine who can rent a car. The rules are: A renter must be 21 years old or older. A renter must have a credit card with $10,000 or more of credit. The program looks something like the cookie program: QUESTION 7: Complete the program by filling in the blanks. Used by permission. Page 8 of 29
9 if ( age>=21 && credit>=10000 ) The customer must get for both the age test and the credit test. If both tests are passed, the && combines the two 's into. More Renters A 24 year old customer with $0 credit could not rent a car. The boolean expression looks like this: age >= 21 && credit >= false false A 19 year old customer with $ credit could not rent a car. The boolean expression looks like this: age >= 21 && credit >= false false QUESTION 8: Could a 30 year old with $10000 credit rent a car? Used by permission. Page 9 of 29
10 A 30 year old with $10000 credit could rent a car. age >= 21 && credit >= Range Testing A welter weight boxer must weight between 136 and 147 pounds. A boxer's weight is tested before each fight to be sure that he is within his weight category. Here is a program that checks if a welter weight boxer's weight is within range: QUESTION 9: Fill the blank so that weight is tested in two ways: weight must be equal or greater than 136 weight must be less than or equal to 147 Used by permission. Page 10 of 29
11 // check that the weight is within range if ( weight >= 136 && weight <= 147 ) System.out.println("In range!" ); else System.out.println("Out of range." ); A Run of the Program The boxer must weigh enough (weight >= 136), and must also not weigh too much (weight <= 147). The results of the two tests are combined with the andoperator, &&. Here is a JavaScript version of the program: QUESTION 10: Run the program for a weight of 140. Used by permission. Page 11 of 29
12 How heavy is the boxer? 140 In range! The andoperator gives because both sides are : weight >= 136 && weight <= >= 136 && 140 <= Tax Bracket An unmarried taxpayer in the US with an income of $24,000 up to $58,150 (inclusive) falls into the 28% "tax bracket." Here is a program that tests if a taxpayer falls into this bracket. QUESTION 11: Fill in the blank to test if the income is within this tax bracket. Used by permission. Page 12 of 29
13 // check that the income is within range for the 28% bracket if ( income >=24000 && income <= ) System.out.println("In the 28% bracket." ); else System.out.println("Time for an audit!" ); Complete Boolean Expressions AND combines the results of two relational expressions, like this: income >= && income <= relational relational expression expression Each relational expression must be complete. The following is a MISTAKE: income >= && <= relational not a complete expression relational expression This is INCORRECT because the characters that follow && do not form a complete relational expression. The Java compiler would not accept this. QUESTION 12: Here is an incorrect boolean expression that is intended to test if a person's age is between 21 and 35. age >= 21 && <= 35 Fix the boolean expression. Used by permission. Page 13 of 29
14 age >= 21 && age <= 35 Either Order (usually) In most situations, the operands of AND can be in either order. The following age >= 21 && age <= 35 is the equivalent of this: age <= 35 && age >= 21 One false is enough to make the entire expression false, regardless of the false occurs. Warning: If a boolean expression includes an assignment operator or method calls, then the order sometimes does matter. The reason for this involves the shortcircuit optimization mentioned previously. Mostly you don't need to worry about this, but make a mental note about this potential problem. Chapter 40 describes this situation in detail. For the examples in this chapter, the order of operands does not matter. QUESTION 13: Examine this expression: ( Monster.isAlive() && (hitpoints = Hero.attack()) < 50 ) Do you suspect that the order of operands in this expression matters? Used by permission. Page 14 of 29
15 Yes, since the expression involves calling methods and also uses an assignment operator. Buying a Car with Cash You would like to buy a $25,000 red Miata sports car. To pay for the car you need either enough cash or enough credit. Let us ignore the possibility of combining cash and credit. QUESTION 14: You found $34,951 in a cookie jar. Can you buy the $25,000 Miata? Used by permission. Page 15 of 29
16 Yes. You have enough money for the car. But what happened to the cookies? Recall the problem: Buying on Credit You would like to buy a new $25,000 red Miata sports car. To buy the car, you could pay cash for it, or you could buy it on credit. You might not have $25,000 on hand. The cookie jar seems to be empty. No problem you can buy on credit, if you qualify. QUESTION 15: You have $240 on hand. The credit manager is willing to extend you up to $30,000 of credit. Can you buy the $25,000 Miata? Used by permission. Page 16 of 29
17 Yes. You have enough credit for the car. Recall the problem: Student Car Purchase You would like to buy a new $25,000 red Miata sports car. You can pay in cash, or you can buy it on credit. It turns out that you actually have $240 on hand and are an unemployed student majoring in philosophy. The credit manager is unwilling to extend any credit to you. QUESTION 16: You have $240 on hand and no credit. Can you buy the $25,000 Miata? Used by permission. Page 17 of 29
18 No. Car Purchase Decision You need money OR credit. Just one would do. Of course, if you had lots of money and plenty of credit you could certainly buy the car. Sometimes a program has to test if just one of the conditions has been met. Here is how that is done with the car purchase problem: The symbol (verticalbar verticalbar) means OR. On your keyboard, verticalbar is the top character on the key above the "enter" key. The OR operator evaluates to when either qualification is met or when both are met. The if statement asks a question with two parts: if ( cash >= credit >= ) cash part credit part If either part is, or both parts are, then the entire boolean expression is. QUESTION 17: Used by permission. Page 18 of 29
19 cash >= credit >= false cash >= credit >= Boolean Expressions with OR The OR operator is used in a boolean expression to check that there is at least one. If both sides are, the entire expression is. If just one side is, the entire expression is. If both sides are false, the entire expression is false. The OR operator is a logical operator because it combines two /false values into a single /false value. Here is how works: = false = false = false false = false OR checks that at least one requirement is met. This type of OR is called an inclusive OR because its value is for one or two values. Often in English word "or" is used when any number of conditions can be. For example, in this sentence Successful job seekers must have experience or training. Sometimes the English word "or" is used when only one condition can be at a time. For example, in this sentence It will rain today or it will be clear. only one condition, "rain" or "clear", can be. This is called an exclusive OR. In programming, "or" means inclusive or. Used by permission. Page 19 of 29
20 QUESTION 18: Here is a boolean expression: 34 > 2 5 == 7 Is this expression or false? Used by permission. Page 20 of 29
21 The boolean expression is 34 > 2 5 == false because all OR needs is one. Car Purchase Program The above expression evaluates to because at least one operand was. In fact, as soon as the first is detected, you know that the entire expression must be, because OR anything is. 34 > 2 5 == does not matter As an optimization, Java evaluates an expression only as far as needed to determine its value. When program runs, as soon as 34 > 2 is found to be, the entire expression is known to be, and evaluation goes no further. This type of optimization is called shortcircuit evaluation. (Just as it is with AND.) Here is a full Java program that implements the car purchase decision. Used by permission. Page 21 of 29
22 Compile and run the program with various values of cash and credit to check that you understand how OR works. QUESTION 19: What does the program do if the user enters negative numbers? Used by permission. Page 22 of 29
23 The program runs. However, it is not clear what negative values mean in this situation. The program could be improved by calling the user's attention to possibly erroneous data. Insulated Wall Problem To meet building code requirements, outside walls of new houses must be well insulated. Say that the building code requires outside walls to be insulated with at least 4 inches of fiberglass batting or with at least 3 inches of foam insulation. Here is a program that asks for the number of inches of fiberglass and the number of inches of foam and determines if a new house meets the building code. QUESTION 20: Fill in the blanks so that the program works correctly. Used by permission. Page 23 of 29
24 if ( fiber >= 4 foam >= 3 ) System.out.println("House passes the code requirements!" ); else System.out.println("House fails." ); Difference between AND and OR Here is what would happen if a house had 6 inches of fiberglass batting and 0 inches of plastic foam: fiber >= 4 foam >= false One is enough. AND is different from OR. Both of them combine Boolean values ( /false values ) into one Boolean value. But each does this in a different way: All the values AND combines must be to get a. At least one of the values OR combines must be to get a. The operation of AND and OR can be displayed in a truth table. In the table, A and B are operands. They stand for /false values or expressions that yield /false values. For example, A could stand for a relational expression such as memory > 512 or a string comparison like phrase.equals( "quit" ). Used by permission. Page 24 of 29
25 Each row of the truth table shows how logical operators combine the /false values of operands. For example, row one says that if A is false and B is false, then A && B is false also A B is false. Row three says that if A is and B is false, then A && B is false also A B is. All possible truth values of the operands A and B are listed in the left two columns. Each operand can take the value or the value false, so there are four possible combinations of values for the two operands. QUESTION 21: Pick or false for each of the following: (Remember that!= means "not equal.") Used by permission. Page 25 of 29
26 NOT! The NOT operator in Java is this:! (exclaimation point). The NOT operator changes to false and false to, as seen in the truth table. This may seem like a silly thing to do, but often it is useful. Sometimes it is more natural to express a condition in a particular way, but the program logic calls for the reverse of what you have written. Time for the NOT operator. Say that you are shopping for new shoes. You are only interested in shoes that cost less than $50. Here is a program fragment: if ( (cost < 50) ) System.out.println("Reject these shoes"); else System.out.println("Acceptable shoes"); QUESTION 22: Fill in the blank so that the program fragment rejects shoes that do not cost less than $50. Used by permission. Page 26 of 29
27 if (!(cost < 50) ) System.out.println("Reject these shoes"); else System.out.println("Acceptable shoes"); (There are other ways to write this fragment. See below.) Example It is important to put parentheses around the entire expression so the NOT is applied correctly. Say that you are considering a pair of $35 shoes. Evaluation proceeds like this:! ( cost < 50 )! ( 35 < 50 ) ! ( T ) F The entire condition evaluates to false and so the false branch of the if statement is selected. The program prints out "Acceptable shoes". QUESTION 23: Is the following program fragment correct? if (!cost < 50 ) System.out.println("Reject these shoes"); else System.out.println("Acceptable shoes"); Used by permission. Page 27 of 29
28 No. In this defective fragment, the NOT (the!) applies directly to cost. Precidence of NOT The NOT operator has high precedence, so it is done before arithmetic and relational operators unless you use parentheses. Examine the following:!cost < illegal: can't use! on an arithmetic variable Since! has high precedence, the above says to apply it to cost. This which won't work, because cost is an integer and NOT applies only to boolean values. QUESTION 24: Look at this fragment: if ( cost < 50 ) System.out.println("Acceptable shoes"); else System.out.println("Reject these shoes"); Is the new fragment equivalent to the original fragment: if (!(cost < 50) ) System.out.println("Reject these shoes"); else System.out.println("Acceptable shoes"); Try a few trial costs with each fragment to see if they are equivalent. Used by permission. Page 28 of 29
29 Yes. The two fragments are equivalent. Often reversing the order of the branches of an if statement makes a program easier to read. End of Chapter Used by permission. Page 29 of 29
Boolean Logic in MATLAB
Boolean Logic in MATLAB When programming, there will be times when you want to control the flow of your code based on certain events occurring or certain values being reached. Primarily, this is handled
More informationWelcome to Basic Math Skills!
Basic Math Skills Welcome to Basic Math Skills! Most students find the math sections to be the most difficult. Basic Math Skills was designed to give you a refresher on the basics of math. There are lots
More informationMathematical Induction
Mathematical Induction In logic, we often want to prove that every member of an infinite set has some feature. E.g., we would like to show: N 1 : is a number 1 : has the feature Φ ( x)(n 1 x! 1 x) How
More informationChapter 5. Selection 51
Chapter 5 Selection 51 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow
More information26 Integers: Multiplication, Division, and Order
26 Integers: Multiplication, Division, and Order Integer multiplication and division are extensions of whole number multiplication and division. In multiplying and dividing integers, the one new issue
More informationLab 4.4 Secret Messages: Indexing, Arrays, and Iteration
Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration This JavaScript lab (the last of the series) focuses on indexing, arrays, and iteration, but it also provides another context for practicing with
More information0.1 Dividing Fractions
0.. DIVIDING FRACTIONS Excerpt from: Mathematics for Elementary Teachers, First Edition, by Sybilla Beckmann. Copyright c 00, by AddisonWesley 0. Dividing Fractions In this section, we will discuss the
More information1 Description of The Simpletron
Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies
More information3. Mathematical Induction
3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)
More informationhp calculators HP 17bII+ Net Present Value and Internal Rate of Return Cash Flow Zero A Series of Cash Flows What Net Present Value Is
HP 17bII+ Net Present Value and Internal Rate of Return Cash Flow Zero A Series of Cash Flows What Net Present Value Is Present Value and Net Present Value Getting the Present Value And Now For the Internal
More informationPreparing cash budgets
3 Preparing cash budgets this chapter covers... In this chapter we will examine in detail how a cash budget is prepared. This is an important part of your studies, and you will need to be able to prepare
More informationUnit 7 The Number System: Multiplying and Dividing Integers
Unit 7 The Number System: Multiplying and Dividing Integers Introduction In this unit, students will multiply and divide integers, and multiply positive and negative fractions by integers. Students will
More informationIndependent samples ttest. Dr. Tom Pierce Radford University
Independent samples ttest Dr. Tom Pierce Radford University The logic behind drawing causal conclusions from experiments The sampling distribution of the difference between means The standard error of
More informationPlaying with Numbers
PLAYING WITH NUMBERS 249 Playing with Numbers CHAPTER 16 16.1 Introduction You have studied various types of numbers such as natural numbers, whole numbers, integers and rational numbers. You have also
More informationBoolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)
Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the
More informationBorrowing Money Standard 7 Assessment
1 Name: Class Period: Borrowing Money Directions: Match each description in the column below with the CORRECT term from the list. Write the letter of the term in the space provided. A. Interest B. Interest
More informationWorking with whole numbers
1 CHAPTER 1 Working with whole numbers In this chapter you will revise earlier work on: addition and subtraction without a calculator multiplication and division without a calculator using positive and
More informationNegative Integral Exponents. If x is nonzero, the reciprocal of x is written as 1 x. For example, the reciprocal of 23 is written as 2
4 (4) Chapter 4 Polynomials and Eponents P( r) 0 ( r) dollars. Which law of eponents can be used to simplify the last epression? Simplify it. P( r) 7. CD rollover. Ronnie invested P dollars in a year
More informationPersonal Financial Manager (PFM) FAQ s
and Present Personal Financial Manager (PFM) FAQ s Watch a Money Desktop Video at http://www.youtube.com/watch?v=dya5o_6ag7c Q: What is PFM? A: Enhanced Online Banking. PFM is an easy way to track spending,
More informationClick on the links below to jump directly to the relevant section
Click on the links below to jump directly to the relevant section What is algebra? Operations with algebraic terms Mathematical properties of real numbers Order of operations What is Algebra? Algebra is
More informationUsing Proportions to Solve Percent Problems I
RP71 Using Proportions to Solve Percent Problems I Pages 46 48 Standards: 7.RP.A. Goals: Students will write equivalent statements for proportions by keeping track of the part and the whole, and by solving
More informationInvestment Appraisal INTRODUCTION
8 Investment Appraisal INTRODUCTION After reading the chapter, you should: understand what is meant by the time value of money; be able to carry out a discounted cash flow analysis to assess the viability
More information7 Literal Equations and
CHAPTER 7 Literal Equations and Inequalities Chapter Outline 7.1 LITERAL EQUATIONS 7.2 INEQUALITIES 7.3 INEQUALITIES USING MULTIPLICATION AND DIVISION 7.4 MULTISTEP INEQUALITIES 113 7.1. Literal Equations
More informationPreAlgebra Lecture 6
PreAlgebra Lecture 6 Today we will discuss Decimals and Percentages. Outline: 1. Decimals 2. Ordering Decimals 3. Rounding Decimals 4. Adding and subtracting Decimals 5. Multiplying and Dividing Decimals
More informationHow To Proofread
GRADE 8 English Language Arts Proofreading: Lesson 6 Read aloud to the students the material that is printed in boldface type inside the boxes. Information in regular type inside the boxes and all information
More informationUsing Casio Graphics Calculators
Using Casio Graphics Calculators (Some of this document is based on papers prepared by Donald Stover in January 2004.) This document summarizes calculation and programming operations with many contemporary
More informationBinary Adders: Half Adders and Full Adders
Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order
More informationOA310 Patterns in Addition Tables
OA310 Patterns in Addition Tables Pages 60 63 Standards: 3.OA.D.9 Goals: Students will identify and describe various patterns in addition tables. Prior Knowledge Required: Can add two numbers within 20
More informationFraction Problems. Figure 1: Five Rectangular Plots of Land
Fraction Problems 1. Anna says that the dark blocks pictured below can t represent 1 because there are 6 dark blocks and 6 is more than 1 but 1 is supposed to be less than 1. What must Anna learn about
More informationReading 13 : Finite State Automata and Regular Expressions
CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model
More informationWRITING PROOFS. Christopher Heil Georgia Institute of Technology
WRITING PROOFS Christopher Heil Georgia Institute of Technology A theorem is just a statement of fact A proof of the theorem is a logical explanation of why the theorem is true Many theorems have this
More information6.080/6.089 GITCS Feb 12, 2008. Lecture 3
6.8/6.89 GITCS Feb 2, 28 Lecturer: Scott Aaronson Lecture 3 Scribe: Adam Rogal Administrivia. Scribe notes The purpose of scribe notes is to transcribe our lectures. Although I have formal notes of my
More informationSO03 Sales Order Processing Administration
SO03 Sales Order Processing Administration SO03 SOP Administration Contents Contents...1 Overview...2 Objectives:...2 Who should attend?...2 Dependencies...2 Credits...3 Convert credit value only...4
More informationif and ifelse: Part 1
if and ifelse: Part 1 Objectives Write if statements (including blocks) Write ifelse statements (including blocks) Write nested ifelse statements We will now talk about writing statements that make
More informationIt Is In Your Interest
STUDENT MODULE 7.2 BORROWING MONEY PAGE 1 Standard 7: The student will identify the procedures and analyze the responsibilities of borrowing money. It Is In Your Interest Jason did not understand how it
More informationCreating Basic Excel Formulas
Creating Basic Excel Formulas Formulas are equations that perform calculations on values in your worksheet. Depending on how you build a formula in Excel will determine if the answer to your formula automatically
More informationChapter 11 Number Theory
Chapter 11 Number Theory Number theory is one of the oldest branches of mathematics. For many years people who studied number theory delighted in its pure nature because there were few practical applications
More informationWriting Thesis Defense Papers
Writing Thesis Defense Papers The point of these papers is for you to explain and defend a thesis of your own critically analyzing the reasoning offered in support of a claim made by one of the philosophers
More informationPart 1 Expressions, Equations, and Inequalities: Simplifying and Solving
Section 7 Algebraic Manipulations and Solving Part 1 Expressions, Equations, and Inequalities: Simplifying and Solving Before launching into the mathematics, let s take a moment to talk about the words
More informationSHELL INDUSTRIAL APTITUDE BATTERY PREPARATION GUIDE
SHELL INDUSTRIAL APTITUDE BATTERY PREPARATION GUIDE 2011 Valtera Corporation. All rights reserved. TABLE OF CONTENTS OPERATIONS AND MAINTENANCE JOB REQUIREMENTS... 1 TEST PREPARATION... 2 USE OF INDUSTRIAL
More informationConditional Statements. 15110 Summer 2010 Margaret ReidMiller
Conditional Statements 15110 Summer 2010 Margaret ReidMiller Conditional statements Within a method, we can alter the flow of control (the order in which statements are executed) using either conditionals
More informationChapter One Introduction to Programming
Chapter One Introduction to Programming 11 Algorithm and Flowchart Algorithm is a stepbystep procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of
More informationSage 50 Accounts Construction Industry Scheme (CIS)
Sage 50 Accounts Construction Industry Scheme (CIS) Copyright statement Sage (UK) Limited, 2012. All rights reserved We have written this guide to help you to use the software it relates to. We hope it
More informationSYSTEMS OF EQUATIONS AND MATRICES WITH THE TI89. by Joseph Collison
SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI89 by Joseph Collison Copyright 2000 by Joseph Collison All rights reserved Reproduction or translation of any part of this work beyond that permitted by Sections
More informationClosing The Sale. What actually happens during the sales process is that the salesperson:
Closing The Sale Closing The Sale By Sean McPheat, Managing Director Of The Sales Training Consultancy Closing the sale is not a skill that can be learned in isolation from the rest of the sales process.
More informationTeaching & Learning Plans. Arithmetic Sequences. Leaving Certificate Syllabus
Teaching & Learning Plans Arithmetic Sequences Leaving Certificate Syllabus The Teaching & Learning Plans are structured as follows: Aims outline what the lesson, or series of lessons, hopes to achieve.
More informationACADEMIC TECHNOLOGY SUPPORT
ACADEMIC TECHNOLOGY SUPPORT Microsoft Excel: Formulas ats@etsu.edu 4398611 www.etsu.edu/ats Table of Contents: Overview... 1 Objectives... 1 1. How to Create Formulas... 2 2. Naming Ranges... 5 3. Common
More informationIntegrated Accounting System for Mac OS X
Integrated Accounting System for Mac OS X Program version: 6.3 110401 2011 HansaWorld Ireland Limited, Dublin, Ireland Preface Standard Accounts is a powerful accounting system for Mac OS X. Text in square
More informationhttps://williamshartunionca.springboardonline.org/ebook/book/27e8f1b87a1c4555a1212b...
of 19 9/2/2014 12:09 PM Answers Teacher Copy Plan Pacing: 1 class period Chunking the Lesson Example A #1 Example B Example C #2 Check Your Understanding Lesson Practice Teach BellRinger Activity Students
More informationOutline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators
Conditional Statements For computer to make decisions, must be able to test CONDITIONS IF it is raining THEN I will not go outside IF Count is not zero THEN the Average is Sum divided by Count Conditions
More informationCounting Money and Making Change Grade Two
Ohio Standards Connection Number, Number Sense and Operations Benchmark D Determine the value of a collection of coins and dollar bills. Indicator 4 Represent and write the value of money using the sign
More informationChapter 3. Cartesian Products and Relations. 3.1 Cartesian Products
Chapter 3 Cartesian Products and Relations The material in this chapter is the first real encounter with abstraction. Relations are very general thing they are a special type of subset. After introducing
More informationTeaching & Learning Plans. Introduction to Equations. Junior Certificate Syllabus
Teaching & Learning Plans Introduction to Equations Junior Certificate Syllabus The Teaching & Learning Plans are structured as follows: Aims outline what the lesson, or series of lessons, hopes to achieve.
More informationCHAPTER 18 Programming Your App to Make Decisions: Conditional Blocks
CHAPTER 18 Programming Your App to Make Decisions: Conditional Blocks Figure 181. Computers, even small ones like the phone in your pocket, are good at performing millions of operations in a single second.
More informationMind on Statistics. Chapter 12
Mind on Statistics Chapter 12 Sections 12.1 Questions 1 to 6: For each statement, determine if the statement is a typical null hypothesis (H 0 ) or alternative hypothesis (H a ). 1. There is no difference
More information8 Primes and Modular Arithmetic
8 Primes and Modular Arithmetic 8.1 Primes and Factors Over two millennia ago already, people all over the world were considering the properties of numbers. One of the simplest concepts is prime numbers.
More information User input includes typing on the keyboard, clicking of a mouse, tapping or swiping a touch screen device, etc.
Java User Input WHAT IS USER INPUT?  Collecting and acting on user input is important in many types of programs or applications.  User input includes typing on the keyboard, clicking of a mouse, tapping
More information2.6 Exponents and Order of Operations
2.6 Exponents and Order of Operations We begin this section with exponents applied to negative numbers. The idea of applying an exponent to a negative number is identical to that of a positive number (repeated
More information**Unedited Draft** Arithmetic Revisited Lesson 4: Part 3: Multiplying Mixed Numbers
. Introduction: **Unedited Draft** Arithmetic Revisited Lesson : Part 3: Multiplying Mixed Numbers As we mentioned in a note on the section on adding mixed numbers, because the plus sign is missing, it
More information2: Entering Data. Open SPSS and follow along as your read this description.
2: Entering Data Objectives Understand the logic of data files Create data files and enter data Insert cases and variables Merge data files Read data into SPSS from other sources The Logic of Data Files
More informationImproved VAT in QuickBooks 2008 & Later
Improved VAT in QuickBooks 2008 & Later Introduction With QuickBooks 2008, we redesigned how VAT is calculated and reported. QuickBooks 2010 brings additional improvements, such as tools to help you upgrade
More informationPercentages. You will need a calculator 20% =
What is a percentage? Percentage just means parts per hundred, for example 20% stands for 20 parts per hundred. 20% is a short way of writing 20 over a hundred. When using a percentage in a calculation
More informationIntroduction to Java
Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high
More informationECON 459 Game Theory. Lecture Notes Auctions. Luca Anderlini Spring 2015
ECON 459 Game Theory Lecture Notes Auctions Luca Anderlini Spring 2015 These notes have been used before. If you can still spot any errors or have any suggestions for improvement, please let me know. 1
More informationSources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
More informationKeywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void
1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of
More informationSimple Regression Theory II 2010 Samuel L. Baker
SIMPLE REGRESSION THEORY II 1 Simple Regression Theory II 2010 Samuel L. Baker Assessing how good the regression equation is likely to be Assignment 1A gets into drawing inferences about how close the
More informationClock Arithmetic and Modular Systems Clock Arithmetic The introduction to Chapter 4 described a mathematical system
CHAPTER Number Theory FIGURE FIGURE FIGURE Plus hours Plus hours Plus hours + = + = + = FIGURE. Clock Arithmetic and Modular Systems Clock Arithmetic The introduction to Chapter described a mathematical
More informationElasticity. I. What is Elasticity?
Elasticity I. What is Elasticity? The purpose of this section is to develop some general rules about elasticity, which may them be applied to the four different specific types of elasticity discussed in
More informationJ a v a Quiz (Unit 3, Test 0 Practice)
Computer Science S111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiplechoice questions are worth 2 points
More informationLINEAR INEQUALITIES. less than, < 2x + 5 x 3 less than or equal to, greater than, > 3x 2 x 6 greater than or equal to,
LINEAR INEQUALITIES When we use the equal sign in an equation we are stating that both sides of the equation are equal to each other. In an inequality, we are stating that both sides of the equation are
More informationSAT Math Facts & Formulas Review Quiz
Test your knowledge of SAT math facts, formulas, and vocabulary with the following quiz. Some questions are more challenging, just like a few of the questions that you ll encounter on the SAT; these questions
More informationMoving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an objectoriented language. This document describes some of the differences between objectoriented programming in Scheme (which we hope you
More informationLife Insurance Buyer's Guide
Life Insurance Buyer's Guide This guide can help you when you shop for life insurance. It discusses how to: Find a Policy That Meets Your Needs and Fits Your Budget Decide How Much Insurance You Need Make
More informationAccentuate the Negative: Homework Examples from ACE
Accentuate the Negative: Homework Examples from ACE Investigation 1: Extending the Number System, ACE #6, 7, 1215, 47, 4952 Investigation 2: Adding and Subtracting Rational Numbers, ACE 1822, 38(a),
More informationLecture 2 Notes: Flow of Control
6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The
More informationWhat is a Loop? Pretest Loops in C++ Types of Loop Testing. Countcontrolled loops. Loops can be...
What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control
More informationName: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1  Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
More informationFile by OCR Manual. Updated December 9, 2008
File by OCR Manual Updated December 9, 2008 edocfile, Inc. 2709 Willow Oaks Drive Valrico, FL 33594 Phone 8134135599 Email sales@edocfile.com www.edocfile.com File by OCR Please note: This program is
More informationSales Training Programme. Module 8. Closing the sale workbook
Sales Training Programme. Module 8. Closing the sale workbook Workbook 8. Closing the sale Introduction This workbook is designed to be used along with the podcast on closing the sale. It is a self learning
More information2007 Choosing a Medigap Policy:
CENTERS FOR MEDICARE & MEDICAID SERVICES 2007 Choosing a Medigap Policy: A Guide to Health Insurance for People with Medicare This is the official government guide with important information about what
More informationLesson 8 Setting Healthy Eating & Physical Activity Goals
Lesson 8 Setting Healthy Eating & Physical Activity Goals Overview In this lesson, students learn about goal setting. They review the activity sheets they filled out earlier to log their eating and activity
More informationAlevel COMPUTER SCIENCE
Alevel COMPUTER SCIENCE Paper 2 TBC am/pm 2 hours 30 minutes Materials There are no additional materials required for this paper. Instructions Use black ink or black ballpoint pen. Fill in the boxes
More informationChapter 8: Fundamentals of Capital Budgeting
Chapter 8: Fundamentals of Capital Budgeting1 Chapter 8: Fundamentals of Capital Budgeting Big Picture: To value a project, we must first estimate its cash flows. Note: most managers estimate a project
More informationwhat operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?
Inside the CPU how does the CPU work? what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored? some short, boring programs to illustrate the
More informationCommon Data Structures
Data Structures 1 Common Data Structures Arrays (single and multiple dimensional) Linked Lists Stacks Queues Trees Graphs You should already be familiar with arrays, so they will not be discussed. Trees
More informationAdding Integers Using a Number Line
Adding Integers The addition of integers can be done in a variety of ways, such as using number lines, manipulatives and a Tchart, calculators or shortcuts. Parentheses (or brackets) are often used around
More informationProgramming Your App to Make Decisions: Conditional Blocks
Chapter 18 Programming Your App to Make Decisions: Conditional Blocks Computers, even small ones like the phone in your pocket, are good at performing thousands of operations in just a few seconds. Even
More informationLecture Notes on Linear Search
Lecture Notes on Linear Search 15122: Principles of Imperative Computation Frank Pfenning Lecture 5 January 29, 2013 1 Introduction One of the fundamental and recurring problems in computer science is
More informationPseudo code Tutorial and Exercises Teacher s Version
Pseudo code Tutorial and Exercises Teacher s Version Pseudocode is an informal way to express the design of a computer program or an algorithm in 1.45. The aim is to get the idea quickly and also easy
More informationThe fundamental question in economics is 2. Consumer Preferences
A Theory of Consumer Behavior Preliminaries 1. Introduction The fundamental question in economics is 2. Consumer Preferences Given limited resources, how are goods and service allocated? 1 3. Indifference
More informationUser guide for the Error & Warning LabVIEW toolset
User guide for the Error & Warning LabVIEW toolset Rev. 2014 December 2 nd 2014 1 INTRODUCTION... 1 2 THE LABVIEW ERROR CLUSTER... 2 2.1 The error description... 3 2.2 Custom error descriptions... 4 3
More informationQuosal Form Designer Training Documentation
Chapter 4 Advanced Form Design Concepts There is a huge amount of customization that can be done with the Report Designer, and basic quote forms only scratch the surface. Learning how to use the advanced
More informationIntegers, I, is a set of numbers that include positive and negative numbers and zero.
Grade 9 Math Unit 3: Rational Numbers Section 3.1: What is a Rational Number? Integers, I, is a set of numbers that include positive and negative numbers and zero. Imagine a number line These numbers are
More informationIntegrated Invoicing and Debt Management System for Mac OS X
Integrated Invoicing and Debt Management System for Mac OS X Program version: 6.3 110401 2011 HansaWorld Ireland Limited, Dublin, Ireland Preface Standard Invoicing is a powerful invoicing and debt management
More informationThe Easy Picture Guide to banking xxxx. Choosing xxxxxxxxxxxxxxxxxxxxx a xxxxxxxxxxxxxxxxxxxxx. bank account
The Easy Picture Guide to banking xxxx Choosing xxxxxxxxxxxxxxxxxxxxx and opening a xxxxxxxxxxxxxxxxxxxxx bank account The Easy Picture Guide to xxxx a bank account The Easy Picture Guide to Money for
More informationYour guide to Using a solicitor
www.lawsociety.org.uk 1 Most of us need expert legal help at some time in our lives. Some of the most common issues are to do with buying a house, getting a divorce or making a will. But you might also
More informationInformatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
More informationPREPARATION MATERIAL FOR THE GRADUATE RECORD EXAMINATION (GRE)
PREPARATION MATERIAL FOR THE GRADUATE RECORD EXAMINATION (GRE) Table of Contents 1) General TestTaking Tips General TestTaking Tips Differences Between Paper and Pencil and ComputerAdaptive Test 2)
More informationHandout #1: Mathematical Reasoning
Math 101 Rumbos Spring 2010 1 Handout #1: Mathematical Reasoning 1 Propositional Logic A proposition is a mathematical statement that it is either true or false; that is, a statement whose certainty or
More information