Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

you built a simple one-function calculator using HTML and Javascript. In this lab you'll extend your calculator to add additional functions. We do this a

you built a simple one-function calculator using HTML and Javascript. In this lab you'll extend your calculator to add additional functions. We do this a lot in programmingtake something that already exists and add things to it.

image text in transcribed

You'll be using Brackets for your coding; if you'd like to install it on your personal computer, it's available at brackets.io Goal: Create a web page that includes two text input boxes and several buttons to implement addition, subtraction, multiplication, division, and powers (ie 27). For the powers function, use the caret symbol (^) for your button. The user enters a number into each text box, clicks a func- tion button, and the result is displayed in a third text box. In addition to the function buttons, pro vide a 'clear' button that erases the contents of all three boxes. lt will look something like: Calc-o-Matic L-Clear Start with your solution for Lab 8 and work from there. As in Lab 8, Javascript functions should be placed, enclosed by , in the section of your HTML file. Usually when I write a function, I use the word do' plus the purpose of the function, so you might name your function 'doAdd. The functions will read the values from each of the two boxes, perform the selected operation, and set the value of the third box to the computed number. Use the 'document.getElementByld' function to get and set the box values, and don't forget to convert the first two values to Numbers. Your calculator may not use the
tag or the eval() Javascript function. All buttons should use an 'onclick' callback to execute the appropriate function. Use a loop implementation for the powers function (it will be similar to the loop you id in lab 6). You may not use the Math.pow) function for powers To calculate a number raised to a power, you multiply the number times itself. For example, 24 is 2* 2 2 2. Your loop would run four times, each time multiplying the result of the previous cal- culation by 2. Before entering the loop, create a variable to hold the result and set it equal to 1 (var result-1;) This lab is just about functionality; in an upcoming lab you'll apply CSS styles to organize the buttons and make the page pretty. Submit your HTML file on Blackboard to complete the as- signment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago