Computer Programming 12 Lesson 3 – Computer Programming Concepts By Dan Lunney.

Slides:



Advertisements
Similar presentations
ALGEBRA 1 BASICS CHEAT SHEET THINGS YOU SHOULD KNOW . . .
Advertisements

Equations and Their Solutions
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Expressions and Operators Program Style.
Chapter 2 Beginning Problem-Solving Concepts for the Computer
Solving Linear Equations
Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition.
Solving Equations by Adding and Subtracting: Vocabulary Solve: To solve an equation mean to find a solution to the equation. Isolate the variable: Get.
Step 1: Simplify Both Sides, if possible Distribute Combine like terms Step 2: Move the variable to one side Add or Subtract Like Term Step 3: Solve for.
WordDefinitionExample Equation A mathematical statement that says two expressions are equal Inequality A mathematical statement that compares two expressions.
CONFIDENTIAL1 Good Afternoon! Today we will be learning about Functions Let’s warm up : Evaluate the following equations: 1) a + 4 = 9 2) b - 4 = 9 3)
Lesson 2 McManus COP  Computational ◦ problems involving some kind of mathematical processing  Logical ◦ Problems involving relational or logical.
Beginning Problem-Solving Concepts for the Computer Lesson 2 McManusCOP10001.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition.
An equation is a mathematical statement that two expressions are equivalent. The solution set of an equation is the value or values of the variable that.
Solving One-Step Equations and Inequalities
Solve Equations with Variables on Both Sides
Variables Tutorial 3c variable A variable is any symbol that can be replaced with a number to solve a math problem. An open sentence has at least one.
1.4 Solving Equations ●A variable is a letter which represents an unknown number. Any letter can be used as a variable. ●An algebraic expression contains.
Section 2.2 More about Solving Equations. Objectives Use more than one property of equality to solve equations. Simplify expressions to solve equations.
 Here are a few review concepts before we start solving equations!
Beginning Problem-Solving Concepts for the Computer
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
Cosc175/operators1 Algorithms computer as the tool process – algorithm –Arithmetic: addition,subtraction,multiplication,division –Save information for.
Arithmetic Expressions Addition (+) Subtraction (-) Multiplication (*) Division (/) –Integer –Real Number Mod Operator (%) Same as regular Depends on the.
Lesson 1.4 Equations and Inequalities Goal: To learn how to solve equations and check solutions of equations and inequalities.
Three Two One Whenever you attempt to solve a problem, there are certain steps you should follow. 1.Define the problem 2.Propose and evaluate.
1 Variables and Arithmetic Operators in JavaScript.
Solve one step equations. You can add the same amount to both sides of an equation and the statement will remain true = = 9 x = y +
Data Handling in Algorithms. Activity 1 Starter Task: Quickly complete the sheet 5mins!
Lesson 8.1. » A statement where two mathematical expressions are. » Think of an equation as a balance scale or teeter-totter. The left side must always.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
A variable is a name for a value stored in memory.
Graphing and Solving Inequalities
BASIC ELEMENTS OF A COMPUTER PROGRAM
Solving Equations with the Variable on Each Side
Object Oriented Programming
Cell phone use is prohibited.
Data Types, Identifiers, and Expressions
Design & Technology Grade 7 Python
Solving 1-Step Integer Equations
Solving for the Unknown: A How-to Approach for Solving Equations
Solving Equations by 2-1 Adding or Subtracting Warm Up
Data Types, Identifiers, and Expressions
6.1 Algebraic Expressions & Formulas
Examples of Primitive Values
Simplify Expressions 34 A number divided by 3 is 7. n ÷ 3 = 7.
Introduction to Algebra
Objective Solve equations in one variable that contain variable terms on both sides.
Variables and Expressions
Introduction to Variables, Algebraic Expressions, and Equations
1.3 Solving Linear Equations
One step equation with Multiplication and Division
Equations and Inequalities
Two Step Equation.
Equation with variables on both sides
One step equation with Addition and Subtraction
Two step equation Operations
SECTION 2-4 : SOLVING EQUATIONS WITH THE VARIABLE ON BOTH SIDES
Objective Solve equations in one variable that contain variable terms on both sides.
Two step equation Brackets
Do Now Evaluate 9h + h if h = 2.1 Evaluate 2 (4 + g) 2 If g = 6.
Working with Formulas and Functions
Algebra: Variables and Expressions
Review of Integers and Solving Equations
Do Now Simplify. 1. 5(7) – (18 – 11)  (40 – 35) (12 – 4)
Solving Equations by 2-1 Adding or Subtracting Warm Up
One Step Equations with Addition and Subtraction
Algebraic Expressions & Solving Equations
Presentation transcript:

Computer Programming 12 Lesson 3 – Computer Programming Concepts By Dan Lunney

Constants and Variables Constants and variables are pieces of data used by a program to solve problems Constants and variables are pieces of data used by a program to solve problems Constants – a value, alphabetical or numerical, that does not change during the processing of all the instructions in a solution Constants – a value, alphabetical or numerical, that does not change during the processing of all the instructions in a solution Variable – a value, alphabetical or numerical, that can change during the processing of all the instructions in a solution Variable – a value, alphabetical or numerical, that can change during the processing of all the instructions in a solution Both constants and variables are assigned names and values Both constants and variables are assigned names and values

Examples Pi = 3.14 (constant) Pi = 3.14 (constant) Radius = 0 (variable) Radius = 0 (variable) Red = “RED” (constant) Red = “RED” (constant) F_Name = “Dan” (variable) F_Name = “Dan” (variable)

Rules for Naming Variables Should be named according to what it represents Should be named according to what it represents No spaces allowed No spaces allowed Must start with a letter Must start with a letter Do not use a dash in name Do not use a dash in name Must be used exactly as named Must be used exactly as named Must be consistent with upper and lower case Must be consistent with upper and lower case

What is wrong with the following variables? Hours Worked Hours Worked CN CN Pay-Rate Pay-Rate Quantity/custom er Quantity/custom er 6%_sales_tax 6%_sales_tax Client_address_ for_clientXYZ_i n_Newfoundlan d Client_address_ for_clientXYZ_i n_Newfoundlan d Hours_Worked Hours_Worked Client_name Client_name Pay_Rate Pay_Rate Quantity_per_c ustomer Quantity_per_c ustomer Sales_Tax Sales_Tax Client_Address Client_Address

Data Types Each variable or constant has a data type Each variable or constant has a data type Data types can be Data types can be Numerical Numerical Characters Characters Logical (on/off or true/false) Logical (on/off or true/false)

Rules for Data Types Come in three common forms: numbers, characters, logical Come in three common forms: numbers, characters, logical Must be designated with the variable when originally named Must be designated with the variable when originally named Cannot be mixed (can’t save text in a numeric variable) Cannot be mixed (can’t save text in a numeric variable) Each data type has a data set i.e. numeric includes 0-9, +, -,. Each data type has a data set i.e. numeric includes 0-9, +, -,. Variables used in calculations must be numeric data type Variables used in calculations must be numeric data type

Examples The price of an item $4.25 The price of an item $4.25 Numeric real Numeric real The name of a company The name of a company Character string Character string A quantity A quantity Numeric integer Numeric integer Credit check (true/false) Credit check (true/false) Logical Logical Phone number Phone number Character string Character string

Functions Functions are small sets of instructions that perform specific tasks and return values Functions are small sets of instructions that perform specific tasks and return values They usually take the form: They usually take the form: Function_name(data) Function_name(data) The data used in a function is called a parameter and is usually stored in a variable The data used in a function is called a parameter and is usually stored in a variable

Functions (cont.) Functions usually are divided into classes: Functions usually are divided into classes: Mathematical functions Mathematical functions SQRT(N) SQRT(N) String functions String functions Left(S, n) Left(S, n) Conversion functions Conversion functions VALUE(String) VALUE(String) Statistical functions Statistical functions AVERAGE(list) AVERAGE(list) Utility functions Utility functions DATE() DATE()

Operators Operators are data connectors used in equations and expressions Operators are data connectors used in equations and expressions There are three categories There are three categories Mathematical operators Mathematical operators Relational operators Relational operators Logical operators Logical operators

Mathematical Operators OperatorSymbolExample OperationResultant Addition Subtraction- 7.5 – Multiplication* 8.0 * Division/9.0/ Integer division \9\42 Modulo division MOD 9 MOD 4 1 Power^3^29

Relational Operators OperatorSymbolExample OperationResultant Equal to = 5 = 7 FALSE Less than < 5 < 7 TRUE Greater than > 5 > 7 FALSE Less than or equal to <= 5 <= 7 TRUE Greater than or equal to >= 5 >= 7 FALSE Not equal to <> 5 <> 7 TRUE

Logical Operators OperatorSymbolExample OperationResultant NotNOT NOT True FALSE AndAND TRUE AND TRUE TRUE OrOR TRUE OR FALSE TRUE

Expressions and Equations An expression processes data An expression processes data Ex. LENGTH * WIDTH Ex. LENGTH * WIDTH An equation stores the resultant of an expression in a variable An equation stores the resultant of an expression in a variable AREA = LENGTH * WIDTH AREA = LENGTH * WIDTH Equations are often called assignment statements because the variable on the left is assigned the value of the expression on the right Equations are often called assignment statements because the variable on the left is assigned the value of the expression on the right Ex. PAY = Rate * Hours Ex. PAY = Rate * Hours

Sample Problem – Lesson 3 Answer the data related questions in the sample problem: Answer the data related questions in the sample problem: See sample problem sheet See sample problem sheet See sample problem sheet See sample problem sheet