Unit of Study: Activity Sheet Three
Total Page:16
File Type:pdf, Size:1020Kb
Activity Sheet Three – Programming One Revised October, 2010 Your Name:_______________________________________ Class Period: _______________ Date: ______________________ UNIT OF STUDY: ACTIVITY SHEET THREE POINT BREAKDOWN ASSIGNMENT POINT VALUE EARNED VOCABULARY 20 POINTS _________ SECTION CHECKPOINT PAGE 49 – NEW BOOK 10 POINTS _________ SECTION CHECKPOINT PAGE 54 – NEW BOOK 10 POINTS _________ SECTION CHECKPOINT PAGE 61 – NEW BOOK 10 POINTS _________ CHAPTER 3 REVIEW ?’ TRUE/FALSE – PAGE 62-63 10 POINTS _________ NEW BOOK PROJECT 3-1 – PAGE 63 10 POINTS _________ NEW BOOK PROJECT 3-2 – PAGE 64 10 POINTS _________ NEW BOOK PROJECT 3-3 – PAGE 64 10 POINTS _________ NEW BOOK PROJECT 3-4 – PAGE 64 10 POINTS _________ NEW BOOK ACTIVITY 3-1 PAGE 66 NEW BOOK 25 POINTS _________ 1 Activity Sheet Three – Programming One Revised October, 2010 PURPLE BOOK LESSON 3 WRITTEN QUESTIONS 14 POINTS _________ Page 125 LESSON 3 PROJ.3-1 10 POINTS _________ LESSON 3 PROJ.3-2 10 POINTS _________ LESSON 3 PROJ.3-3 10 POINTS _________ LESSON 3 PROJ.3-5 10 POINTS _________ LESSON 3 PROJ3-7 10 POINTS _________ LESSON 3 PROJ.3-9 10 POINTS _________ LESSON 3 PROJ.3-10 10 POINTS _________ CRITICAL THINKING 3-1 Essay 25 POINTS _________ **The topic has changed – see inside of packet for change TOTAL POINTS POSSIBLE 234 _________ GENERAL COMMENTS… 2 Activity Sheet Three – Programming One Revised October, 2010 YOUR NAME: CLASS PERIOD: Activity Sheet One - This activity will incorporate reading and activities from Fundamentals of C++ (Introductor y) and, Introduction to Computer Science Using C++. Both books can be found in the Programming area of the classroom, and must be returned at the end of the period. Fundamentals of C++ Activiites – Lesson 3 Unit 1 – More Problem-Solving Fundamentals: Calculation and Input – Pages 65 - 130 Objectives – Upon completion of this lesson, you should be able to: Use data of types int and double in arithmetic expressions. Identify mixed-mode expressions and convert data to different types when necessary. Understand the utilization of memory for storing data. Declare, initialize, and use variables in expressions, assignment statements, and output statements. Use the standard input stream and its operator to get data for a program. Declare and use string variables. Know how character data are represented in computer memory. Use constants, library functions, and member functions in programs. Vocabulary BLITZ – below you will define words that you will come across in your reading of this chapter. YOU WILL KEY IN THE TERM AND DEFINITION USING EITHER WORK OR NOTEPAD. 1 POINT EACH 1. ++ operator 2. - - operator 3. arithmetic operators 4. assignment statement 5. assignment operators 6. binary arithmetic 7. compound assignment 8. constant 9. decrementing 10. E notation 11. expression 12. incrementing 13. integer overflow 14. member function 15. modulus 16. order of operations 17. overflow 18. parameter 19. truncate 20. underflow 3 Activity Sheet Three – Programming One Revised October, 2010 Notes from Section 3.1 – Arithmetic in C++ Basic operations for integers – integer arithmetic in C++ allows the operations of addition, subtraction, multiplication, division, and modulus. Modulus - % - enables the remainder to be displayed for example 17 % 3 = 2 – The order of operations – Please Excuse My Dear Aunt Sally – do you know the order of operations? Integer overflow occurs when an operation produces a number outside of your machine’s range. Modulus is restricted to data of type int! Overflow occurs when the area for storage does not enable the data to be stored, so it “flows” to another are of memory. Mixed-mode expressions happens when two or more types of data are used. Notes from 3.2 – Using Variables – page 73 Memory Locations – Sometimes we store data for later use. We put this data in memory locations. We store them in places labeled with variables or constants. Who is Herman Hollerith??? Assignment Statements – we sometimes give value to our variables. Remember, we must assign values of constants when declaring just by the definition of a constant. The assignment operator is ‘ = ‘ int a = 3; //this is an assignment statement – you are initializing a to the value of 3 Compound Assignment – example x = x + y can be written x += y 4 Activity Sheet Three – Programming One Revised October, 2010 Notes for section 3.3 – Input - SHOULD BE REVIEW! Data in our scenario will be inputted through the keyboard. cin is the code for input iostream.h enables cin the extractor operator enables you to get input cin >> double length; cin >> length; //this will get the value of length from the keyboard When we get input that is not numeric, we are collecting s character literal or sting. Regular cin enables you to only get one word at a time with no spaces. Such as dog. You could not store your fullname in a variable by using cin. Using regular cin >> AND getline can lead to problems 2 Ways to avoid the problem 1. Reverse the order of the inputs, with getline being called before cin >>. 2. In cases where you must call cin >> before getline, you must use cin.ignore(); cin.ignore() is a function call to clear out the stream. Discussion of Copyright – what do you think of copyright law??? 5 Activity Sheet Three – Programming One Revised October, 2010 CHAPTER THREE – INTRO TO COMPUTER SCIENCE USING C++ - Third Edition Page 42 Begins the Chapter.. Objectives of the Chapter o Use the assignment and arithmetic operators. o Use operators in output statements. o Explain the problem with division by zero. o Increment and decrement variables. o Explain the order of operations. o Properly mix data types in calculations. o Avoid overflow and underflow in calculations. o Explain floating point rounding errors. The Fundamental Operators – Assignment Operator Simply put the = sign is the assignment operator. It “assign” the identifier with a value. STEP BY STEP – 3.1 – ANALYZE THE PROGRAM… Note, that i = 10000; //this is how you use the assignment operator You can reassign an identifier also – see program. Note that… You can assign identifiers of the same data type at one time.. int i, j, k; i = j = k = 25; STEP BY STEP 3.2 – ANALYZE THE PROGRAM… 6 Activity Sheet Three – Programming One Revised October, 2010 Arithmetic Operators + addition - subtraction * multiplication / division % modulus - note that modulus outputs the remainder of a division problem STEP BY STEP – 3.3 - RETRIEVE FILE FROM FOLDER INSTRUCTOR TELLS YOU IT IS IN – ANALYZE THE PROGRAM…. More about modulus – may be only used for integer division. STEP BY STEP 3.4 – ENTER THIS PROGRAM AND SAVE TO YOUR FOLDER – ANALYZE THE OUTPUT. STEP BY STEP 3.5 – MODIFY THE PROGRAM YOU DID IN 3.4. Dividing by Zero- In mathematics, division by zero is without a practical purpose, The same is true with computers. TRY RUNNING THE PROGRAM IN STEP BY STEP 3.5 AND ENTER ZERO FOR DIVISOR. ASSIGNMENT – PAGE 49 SECTION CHECKPOINT – 2 POINTS EACH – 10 POINTS Answer the questions in the area below. 1. 2. 3. 4. 5. 3.2 – Counting by One and the Order of Operations Adding or subtracting 1 from a variable is very common on programs. Adding 1 to a variable is called incrementing and subtracting 1 from a variable is called decrementing. 7 Activity Sheet Three – Programming One Revised October, 2010 STEP BY STEP 3.7 – RETRIEVE FILE AND RUN – ANALYZE PROGRAM – SEE EXAMPLES ON BOARD… Placement of the operators can and will make a difference in some programs. STEP BY STEP 3.8 – MODIFY THE PREVIOUS PROGRAM AS DIRECTED Order of Operations – You know the order of operations counts in C++ too! STEP BY STEP 3.9 – RETRIEVE THE FILE AS DIRECTED AND ANALYZE. ASSIGNMENT – PAGE 54 SECTION CHECKPOINT – 2 POINTS EACH Answer the questions in the space provided.. 1. 2. 3. 4. 5. 3.3 – How Data Types Affect Calculations Mixing Data Types C++ can handle the mixing of data types, but one must think about what data they need or expect when writing programs. Promotion is used by C++ to make adjustments to data. STEP BY STEP 3.10 – RETRIEVE THE FILE AS DIRECTED.. Truncation occurs when numbers are dropped off by the mixing of data. STEP BY STEP 3.11 – RETRIEVE THE FILE AS DIRECTED AND ANALYZE.. Overflow and underflow occur when the data types assigned do not hold enough or too much memory for the process. STEP BY STEP 3.13 – RETRIVE THE FILE AS DIRECTED AND ANALYZE… STEP BY STEP 3.14 – ENTER PROGRAM AS DIRECTED AND ANALYZE… 8 Activity Sheet Three – Programming One Revised October, 2010 E notation is used to represent scientific numbers… 3.5 x 10(20) = 3.5E20 It is important to have the right type of data types for scientific use because the numbers can get large! STEP BY STEP 3.15 – ENTER PROGRAM AS DIRECTED AND ANALYZE.. ASSIGNMENT PAGE 61 SECTION CHECKPOINT – 2 POINTS EACH (answer the questions in space below) 1. 2. 3. 4. 5. ASSIGNMENT – PAGE 62-63 – 1POINTS EACH TRUE/FALSE – CIRLCE A “T” FOR TRUE AND “F” FOR FALSE FOR EACH QUESTION… 1 T F 2 T F 3 T F 4 T F 5 T F 6 T F 7 T F 8 T F 9 T F 10 T F 9 Activity Sheet Three – Programming One Revised October, 2010 PROJECT TIME – PAGE 63,64,65,66 – SEE POINT VALUES AS NOTED!!! PRINT OUT SOURCE CODE FOR EACH PROJECT. PROJECT 3-1 – 10 POINTS PROJECT 3-2 – 10 POINTS PROJECT 3-3 – 10 POINTS PROJECT 3-4 – 10 POINTS ACTIVITY 3-1 – 25 POINTS Notes about projects ASSIGNMENT STARTS PAGE 125 IN PURPLE BOOK – Written Questions 1,2, 3, 14, 15, 16, 17 – 2 POINTS EACH Lesson 3 Projects – Proj 3-1 – save as purple3-1 - Proj 3-2 – save as purple3-2 - Proj3-3 – save as purple3-3 - Proj3-5 – save as purple3-5 - Proj3-7 – yep you got it! - Proj3-9 – you get it - Proj3-10 – “” EACH ONE OF THESE IS WORTH 10 POINTS – HAPPY PROGRAMMING! 10 Activity Sheet Three – Programming One Revised October, 2010 Finally Critical Thinking Activities Activity 3-1 – worth 25 points also Using the Internet, research articles concerning cyber bullying and bullying of students in general, write a 500 word essay concerning this topic and your reaction to the topic.