##Scope
This project involves implementing the core functionality of a two-operand, integer calculator. The objective of this project is for students to practice creating variables and functions. They will also learn to research existing functions and call them when necessary.
##Before Class
Students should only start this project after they have completed the other lessons in the unit.
See here for code and here to view.
See here for JS Bin environment.
See here for code (private).
Students will show progress toward reaching the objective based on their ability to create a functioning calculator.
##During Class
###Do Now
- Volunteer takes attendance. Procedure found here.
###Opening
What is a calculator? How do we use one? Let's walk through every step we have to go through to figure out 10+11.
For 10+11, what are the operands? What's the operator? And what's the result?
###Introduction to New Material ("I Do") You are going to build the guts of a two-operand, integer calculator. You will be given some starter code. Instructions:
You are to modify/add the functions we need to make this entire calculator functional. These functions will be added below line 135 in the JavaScript file. Students should not manipulate code above line 135 You will add the following functions:
multiply(x,y);
subtract(x,y);
add(x,y);
power(x,y);
square_root(x);
logBase10(x);
generateRandomNumber();
Note that divide(x,y)
is already implemented for you as a sample.
Additional guidelines:
- Your functions must be named the same and take in the same parameters.
- Do not modify any of the other files.
- Note that the "log" button is not natural log (base e) but log base 10.
- The random number button should generate a number between 1 and 1000.
###Guided Practice ("We Do") Brainstorming! Before you start coding, identify the list of steps you need to do to finish this project. Here's a start:
- On paper, write down the formulas for each of the functions. Note the parameters you have to deal with.
- Bring the starter code into your own environment.
- Successfully solve your favorite function. Make sure it works before moving on to others.
###Independent Practice ("You Do") It's build time! Students should clone the environment found at http://jsbin.com/kezopi/1/edit?html,js,output. Students should only change code below line 135 unless they are working on an extension activity
Students will work alone on this project. The teacher's role will be to walk around the room helping students with any questions they have. Students are encouraged to look at previous lessons for reference.
###Extension Activities Students who complete the project early may attempt to improve their project by including the following:
- Added CSS for visual customization
- Add a factorial button to the calculator.
- A quadratic formula button to the calculator.
###Closing Select students to present their work to the class.
###Check for Understanding Teachers should keep track of student success while they are presenting to the class.
###How to Submit Project
- The students must export this project as a Gist: File > Export as Gist
- Students must submit their Gist URL at the project submission link found in the header of the Daily Session Document.