Java Programming Unit 3: Variables and Arithmetic Operations Bensalem Township School District Standards Link: PA State Standards for Business Education: http://www.pdesas.org/standard/views#114,115,116,117 14121 0 0 15.4.12.H: Use programming languages to develop logical thinking and problem solving skills. 15.4.12.I: Compare and contrast programming languages; select most appropriate one to complete a specific task. Indiana Department of Education Academic Standards, 4534 (COMP PROG) http://dc.doe.in.gov/standards/academicstandards/printlibrary/bme.shtml CP 2.1 Demonstrate a basic understanding of the different data types. CP 2.1.1 Explain variables and constants. CP 2.1.2 Identify different variable types. CP 2.1.3 Describe the syntax rules for naming variables and constants. CP 2.2 Use variables and constants in a program. CP 2.2.1 Apply the syntax rules for naming variables. CP 2.2.2 Declare variable types in the program code. CP 2.2.3 Define constants in the program code. CP 2.2.4 Initialize variables and constants. CP 2.3 Design procedures for manipulating variables and constants. CP 2.3.1 Construct programming statements that modify variables. CP 2.3.2 Construct programming statements that incorporate constants. CP 4.1 Develop an understanding of the programming development life cycle. CP 4.1.1 List and explain in sequence the steps used in problem solving. CP 4.1.2 Define algorithm. CP 4.1.3 List and explain tools used in developing the algorithm. CP 4.2 Practice using the steps in the program development life cycle. CP 4.2.1 Practice identifying what the program should do (program analysis). CP 4.2.2 Plan the solution by developing an algorithm (program design). CP 4.2.4 Translate the algorithm into code. CP 4.2.5 Test the data (debug). CP 4.2.6 Document the program. CP 4.3 Convert algorithms to programs using program development tools. CP 4.3.1 Diagram the logical steps for the algorithm using one of the design tools. CP 7.1 Demonstrate a basic understanding of math operations. CP 7.1.1 Identify arithmetic operators. CP 7.1.2 Recognize the order of operations. CP 7.1.3 Interpret mathematical formulas. CP 7.1.4 Explain the purpose of incrementing and decrementing in a program. CP 7.1.5 Describe the ramifications of dividing by zero. CP 7.2 Apply mathematical operations in programs. CP 7.2.1 Construct formulas using mathematical operators. P:\High School\BusTechDept\Current UBD Docs\-Java\Java - 03 - DataTypes & Variables.doc Page 1 of 6
Java Programming Unit 3: Variables and Arithmetic Operations Bensalem Township School District Standards Link: CP 7.2.2 Solve formulas using order of operations. CP 7.2.3 Construct code that utilizes division by zero (results in an error). CP 7.3 Analyze mathematical operations in programs. CP 7.3.1 Discover the effects of incrementing and decrementing in formulas. CP 7.3.2 Examine the results of division by zero in a formula. CP 7.3.3 Create programs that use mathematical formulas to solve problems. Common Core (Cross Curricular) (CC) Subject Area - 1: Reading, Writing, Speaking, and Listening 1.1.9.A: Apply appropriate comprehension strategies to interpret and evaluate an author s implied or stated purpose using grade level text. Anchor Descriptor - R11.A.2.1.2: Identify and/or apply meaning of content-specific words used in text. 1.1.9.B: Use context clues, knowledge of root words, and word origins as well as reference sources to decode and understand new words. Anchor Descriptor - R11.A.1.1: Identify and apply the meaning of vocabulary. 1.1.11.C: Analyze textual context to determine or clarify the meaning of unfamiliar or ambiguous words and to draw conclusions about nuances or connotations of words. 1.6.9.A: Listen critically and respond to others in small and large group situations. (CC) Subject Area - 2: Mathematics 2.1.11.A: Model and compare values of irrational and complex numbers. Anchor Descriptor - M11.A.1.1: Represent and/or use numbers in equivalent forms (e.g., integers, fractions, decimals, percents, square roots, exponents and scientific notation). 2.5.11.A: Develop a plan to analyze a problem, identify the information needed to solve the problem, carry out the plan, check whether an answer makes sense, and explain how the problem was solved in grade appropriate contexts. 2.5.11.B: Use symbols, mathematical terminology, standard notation, mathematical rules, graphing and other types of mathematical representations to communicate observations, predictions, concepts, procedures, generalizations, ideas, and results. Big Idea: Enduring Understanding(s): Coding Conventions Variables Assignment Statements Conventions are not created, they evolve. Whether in your personal life or professional career, knowledge of conventions and correctly applying them will play a significant role in your success. There are very few absolutes in life. Variables and constants are a part of every choice and every decision you make. No application is mathless. P:\High School\BusTechDept\Current UBD Docs\-Java\Java - 03 - DataTypes & Variables.doc Page 2 of 6
Essential Question(s): What conventions exist in school and at home? What are the parallels between personal, social, and professional conventions and how do they relate to how you approach code? How does knowledge of data types improve your ability to make effective coding decisions? How does declaring a constant differ from declaring a variable? Why is that? Why are some of the arithmetic operators used in coding different from the ones you use in Algebra class? Why is the order of operations important and universal? Knowledge: An identifier is a name assigned to a method, a variable, or any other user-defined item. (CP 2.2, CP 2.3) Identifiers may not contain special symbols other than the Underscore or dollar sign. A variable is an area of storage defined to hold a specific type of data; the actual value stored there can change. Names of variables should begin with a lowercase letter, but may begin with an underscore or a dollar sign. A constant is an area of storage defined to hold a specific type of data and value; the value stored cannot be changed during program execution. Names of constants should be keyed in all capital letters. Names of identifiers cannot contain. Using variables and constants Skill(s): Analyze an application and identify the variables and constants that could/would be established (CP 2.1.1). Write declaration statements with and without initializers. (CP 2.2.1, CP 2.2.2, CP 2.2.3, CP 2.2.4). Identify valid/invalid identifiers. (CP 2.1.3, CP 2.2.1) Apply the syntax rules for naming variables. Declare variable types in the program code. Define constants in the program code. Initialize variables and constants. Identify arithmetic operators. Recognize the order of operations. Interpret mathematical formulas. Explain the purpose of incrementing and decrementing in a program. Describe the ramifications of dividing by zero. Construct formulas using mathematical operators. Solve formulas using order of operations. Construct code that utilizes division by zero (results in an error). Examine the results of division by zero in a formula. Discover the effects of incrementing/decrementing in formulas. Create programs that use mathematical formulas to solve problems. P:\High School\BusTechDept\Current UBD Docs\-Java\Java - 03 - DataTypes & Variables.doc Page 3 of 6
Knowledge: Skill(s): Math Operations 1. Assignment Statements Identifying what the program should do (analysis). Plan the solution by developing an algorithm (design). Construct assignment statements for a variety of applications found on the PSSA formula sheet. (CP 4.2.4, CP 7.1.2, CP 7.2.1, CP 7.3.3) 2. The special operators ++ (Increment) and (decrement) are shorthand. Construct programming statements that modify variables. Construct programming statements that incorporate constants. The special operators +=, =, *=, and /= eliminate the need to repeat the receiving variable in the assignment statement. 3. Program development cycle Putting it all together Assessment/Evidence of Learning: Formative: Teacher observation Informal assessment on a variety of class activities to include drill and review work. Summative: Documented applications that demonstrate the ability to prepare an IPO chart, flowchart, code, compile, P:\High School\BusTechDept\Current UBD Docs\-Java\Java - 03 - DataTypes & Variables.doc Page 4 of 6
Assessment/Evidence of Learning: and execute a Java program that requires the use variables and one or more assignment statements. Objective test designed to measure degree of conceptual competence. It includes sample code to debug, interpret, and analyze. Learning Activities: Resources: Jigsaw the tutorials to explore the concepts of variables and constants. Student teams develop and share working definitions of these terms. Lecture / use slide presentation on data types. Flash cards to drill/assess recognition of integers and floating point data. Guided practice in declaring and initializing variables. Discuss conventions and rules in naming variables. Illustrate how various data types are displayed. Trial and error to explore potential issues. Practice naming, declaring, and initializing variables. Present the arithmetic operators (+, -, /, *, %) and review the order of operations to include a definition of precedence and associativity. Define binary and unary operations. Practice integer math using teacher created assignments. Practice floating-point math using teacher created assignments. Discuss implicit casting and practice mixed-mode math using teacher created assignments. Present syntax of the assignment statement. Using PSSA formula sheet, practice coding C++ assignment statements from algebraic formulas. Present the increment and decrement operators as both prefixes and postfixes. Guided practice to explore the concept of incrementing and decrementing and the differences in using them as a prefix and postfix. Guided practice to play with division by zero. Present flowcharting symbols. Students create an illustrated note sheet. Textbook DataTypes.ppt Teacher-created assignments to practice precedence and associativity of math operations. PSSA formula sheet. Teacher-created assignments to practice creating flowcharts from algorithms. Intra-net delivered pre/post assessments (informal). Debugging activities ExamView software supplied through textbook publishers. On-line tutorials P:\High School\BusTechDept\Current UBD Docs\-Java\Java - 03 - DataTypes & Variables.doc Page 5 of 6
Learning Activities: Resources: Using an activity from the textbook (pp 130-131), work with students to: Create an IPO to include a formal algorithm. Guided Practice in creating a flowchart from an algorithm. Independent student practice on coding from flowcharts/algorithms. Independent student practice on preparing fully documented applications. Debugging activities; identifying valid/invalid assignment statements. Team Project develop an application using variables, constants, assignment statements. Fully document and present to class using ppt. Results are peer reviewed. P:\High School\BusTechDept\Current UBD Docs\-Java\Java - 03 - DataTypes & Variables.doc Page 6 of 6