Add 2 Numbers using a Function Input Number 1 Input Number 2 Call a function that adds these numbers Write the answer out to screen.

Slides:



Advertisements
Similar presentations
QUIZ-A QUICK PROGRESS CHECK ON YOUR UNDERSTANDING.
Advertisements

Enter question text... 1.Enter answer text.... Enter question text... 1.Enter answer text...
Enter question text... 1.Enter answer text.... Enter question text... 1.Enter answer text...
JavaScript with Input & Output Step 1: Use tags JavaScript Template.
Special Sum The First N Integers. 9/9/2013 Sum of 1st N Integers 2 Sum of the First n Natural Numbers Consider Summation Notation ∑ k=1 n k =
In a not gate, if the input is on(1) the output is off (0) and vice versa.
Consecutive Numbers Algebra I.
Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing.
Generating Number Sequences
Machine level architecture Computer Architecture Basic units of a Simple Computer.
Average Atomic Mass The weighted average of the masses of all the naturally occurring isotopes of an element.
Algebra I Notes Section 9.5 (A) Factoring x 2 + bx + c With Leading Coefficient = 1 To factor a quadratic expression means to write it as a product of.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Fraction Review TAKE NOTES!!!!!!. Vocabulary Numerator: the number on top in a fraction Denominator: the number on bottom in a fraction Example: What.
STEP 1 Multiply the digits in the ones place. Write the product in the ones place of the answer box. If the product is greater than ten, carry the number.
Integer Operations Finding a temperature Higher or Lower 5 Examples Adding / Subtracting Integers using a scale Adding / Subtracting Integers by description.
Composite Functions f(g(x)) = f o g(x) 1) Start with inside function first. Steps of evaluating composite functions. Evaluate g(x) 2) Use your result.
Reasonableness with Fractions and Decimals 1.Find what whole numbers the first decimal or fraction would be between. 2.Write the two numbers down. For.
Math – What is a Function? 1. 2 input output function.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 5 JavaScript.
The length of a rectangle is 6 in. more than its width. The perimeter of the rectangle is 24 in. What is the length of the rectangle? What we know: Length.
Right click on the tomato and choose “animation” Go on scribble Right click 2 3.
WRITING ABOUT MATH. FIRST…ANSWER THE QUESTION Question: How can you get the sum of 9 + 4? Answer: You can get the sum of 9+4 by adding 4 to 9, which is.
Reverse Subtraction Objectives:  do a subtract by adding  check your answer by adding.
Patterns and Sequences Sequence: Numbers in a specific order that form a pattern are called a sequence. An example is 2, 4, 6, 8, 10 and 12. Polygon:
Calculus Midterm review!!!. HOW IT WORKS EVERYONE STARTS WITH 100 POINTS WRITE YOUR ANSWER TO THE QUESTION ON THE SCREEN WAGER A POINT AMOUNT (YOU CAN’T.
Copyright©amberpasillas – (- 0.34) 4 Step 2: Line up the decimals Step 3: If needed, put zeros in as place holders Step 4: Add decimals.
Plotting Data & the Finding Regression Line. Clear Old Data 2 nd MEM 4 ENTER.
Chapter 1: Subtraction!!. Section 1- Subtraction with Pictures.
RECURSION & CALCULATOR Calculators are magic!! We can get the calculator to determine each term in a sequence. We input the sequence just like the recursion.
Multiplication
Matrices Rules & Operations.
Click the mouse button or press the Space Bar to display the answers.
Consecutive Numbers Algebra I.
Subtracting Integers.
Knowing your math operation terms
Multiplication
Introduction to Algorithm – part 1
Working with BODMAS Bill Haining presents.
مفاهیم بهره وري.
סדר דין פלילי – חקיקה ומהות ההליך הפלילי
الوحدة الرابعة البرمجة وصياغة حل المسائل البرمجة وأهميتها أهداف الدرس الأول مفهوم البرمجة. الفرق بين المبرمج ومستخدم البرنامج. الحاجة إلى البرامج.
Explanation of Grades to Numbers
Function Notation “f of x” Input = x Output = f(x) = y.
Number Systems and Circuits for Addition

Objective - To add and subtract decimals.
Solving Systems of Equation by Substitution
Suppose I want to add all the even integers from 1 to 100 (inclusive)
CS150 Introduction to Computer Science 1
LMC Little Man Computer What do you know about LMC?
Subtracting Real Numbers
Relations.
Puzzle A Puzzle B.
Unit 1 Section 3C: FACTORING POLYNOMIALS
CATEGORY ONE Enter category name on this slide..
Adding fractions with like Denominators
You must show all steps of your working out.
1st Individually brainstorm and write down everything you remember from the Constitution! People Vocabulary Places Documents Constitution.
Question 1.
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Warm-up: Simplify. Put in standard form.
1st Class Levers 2nd Class Levers 3rd Class Levers
1st Class Levers 2nd Class Levers 3rd Class Levers
Whole Number Mental Add and Subtract
Whole Number Mental Add and Subtract
Whole Number Mental Add and Subtract
Whole Number Mental Add and Subtract
Whole Number Mental Add and Subtract
Chapter 5 JavaScript Numbers and Expressions
Presentation transcript:

Add 2 Numbers using a Function Input Number 1 Input Number 2 Call a function that adds these numbers Write the answer out to screen

Step 1: Put in tags

Step 2: Input 2 Numbers number1= prompt("Enter 1st number:", 0); number2= prompt("Enter 2nd number:", 0);

Step 3: Create a function to add 2 numbers function Add2Numbers(number1, number2) { total=number1+number2; } number1= prompt("Enter 1st number:", 0); number2= prompt("Enter 2nd number:", 0);

Step 4: Call the Function function Add2Numbers(number1, number2) { total=number1+number2; } number1= prompt("Enter 1st number:", 0); number2= prompt("Enter 2nd number:", 0); Add2Numbers(number1, number2);

Step 5: Write the answer out to screen function Add2Numbers(number1, number2) { total=number1+number2; } number1= prompt("Enter 1st number:", 0); number2= prompt("Enter 2nd number:", 0); Add2Numbers(number1, number2); document.write("The sum of the numbers you entered is: "+total);

Step 5: Write the answer out to screen total=0; function Add2Numbers(number1, number2) { total=number1+number2; } number1= prompt("Enter 1st number:", 0); number2= prompt("Enter 2nd number:", 0); Add2Numbers(number1, number2); document.write("The sum of the numbers you entered is: "+total); Problem!!! The output of this program is (with input 1,2): The sum of the numbers you entered is: is the wrong answer, it should be 3 How do we fix this??

Step 6: Fix the problem total=0; function Add2Numbers(number1, number2) { total=number1+number2; } number1= prompt("Enter 1st number:", 0); number2= prompt("Enter 2nd number:", 0); number1=parseInt(number1); number2=parseInt(number2); Add2Numbers(number1, number2); document.write("The sum of the numbers you entered is: "+total);