Activity Sheet Three – Programming One Revised October 2012 Your Name:______
Class Period: ______
Date: ______
UNIT OF STUDY: ACTIVITY SHEET THREE
POINT BREAKDOWN
ASSIGNMENT POINT VALUE EARNED
VOCABULARY 14 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-4 – PAGE 64 10 POINTS ______NEW BOOK
ACTIVITY 3-1 PAGE 66 NEW BOOK 25 POINTS ______
TOTAL POINTS POSSIBLE 109 ______
GENERAL COMMENTS…
1 Activity Sheet Three – Programming One Revised October 2012 YOUR NAME: CLASS PERIOD:
Activity Sheet One - This activity will incorporate reading and activities Introduction to Computer Science Using C++.
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.
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. expression 7. incrementing 8. order of operations 9. overflow 10. promotion 11. quotient 12. remainder 13. truncate 14. underflow
Notes 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.
2 Activity Sheet Three – Programming One Revised October 2012 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.
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
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…
Arithmetic Operators + addition - subtraction * multiplication / division % modulus - note that modulus outputs the remainder of a division problem
3 Activity Sheet Three – Programming One Revised October 2012
STEP BY STEP – 3.3 - RETRIEVE FILE FROM FOLDER INSTRUCTOR TELLS YOU IT IS IN – ANALYZE THE PROGRAM….These files should be on the resource drive. They are in a folder called GREEN BOOK FILES. **Copy the file to your personal network drive before altering.
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.
ASSIGNMENT – PAGE 49 – Type up on your assignment sheet.
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.
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.
4 Activity Sheet Three – Programming One Revised October 2012 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…
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..
5 Activity Sheet Three – Programming One Revised October 2012 ASSIGNMENT PAGE 61
SECTION CHECKPOINT – 2 POINTS EACH (answer the questions in space below)
1. 2. 3. 4. 5.
ASSIGNMENT – PAGE 62-63 – 1 POINT EACH TRUE/FALSE –Write True or False on your assignment paper. 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
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
6 Activity Sheet Three – Programming One Revised October 2012
PROJECT 3-4 – 10 POINTS
ACTIVITY 3-1 – 25 POINTS
Notes about projects
7