Create a function named calcexpression

Assignment Help Web Project
Reference no: EM131777660

The calculator is actually a Web table using CSS styles to give it the appearance of a calculator. Each calculator button is a form button and the calculator screen is a textarea element. When a user clicks a calculator button, the number or symbol represented by the button should be appended to the text on the calculator screen.When the user clicks the equal button ( = ), the calculator should evaluate the expression and display the calculated value. When the user clicks the Clear button, the text in the calculator screen should be replaced with an empty text string. Finally, when the user clicks the backspace button (<-), the browser should remove the last character on the calculator screen. To aid you in programming the backspace key, Theresa has provided a function named erase(). You will create all of the other JavaScript functions yourself. Complete the following:

1. Use your text editor to open the calctxt.htm file from the tutorial.11\case2 folder included with your Data Files. Enter your name and the date in the comment section of the file. Save the file as calculator.htm in the same folder.

2. In your text editor, scroll down to the Web table elements and locate the input elements for the 0 through 9 buttons; the / , * , - , and + buttons; the ( and ) buttons; and the . button. For each of those 17 buttons, add an onclick attribute to run the statement calcPress(' value ')where value is the number or character displayed on the button.

3. Locate the input element for the Clear button and add an onclick attribute to run the clearWin() function when the button is clicked.

4. Locate the input element for the backspace button ( <- ) and add an onclickattribute to run the erase() function when the button is clicked.

5. Add an onclick attribute to the equal button (=) to run the calcExpression() function when the button is clicked.

6. Scroll to the top of the file and add the calcPress() function to the embedded script element. The purpose of this function is to append a symbol to the text displayed in the calculator screen. The calcPress() function should include the following:

a. A single parameter named symbol
b. A command that uses the += operator to add the value of the symbol parameter to the value of the calcwindow field within the calculator form

7. Create a function named calcExpression() . The purpose of this function is to append the calculated value to the expression displayed on the calculator screen. The function has no parameters. Add the following commands:

a. Declare a variable named cString that is equal to the text contained in the calcwindow field of the calculator form.
b. Use the eval() method to store the numeric value of cString in a variable named cvalue .
c. Change the text string value of the calcwindow field from the calculator form to cString = cValue where cString is the value of the cString variable and cValue is the value of the cValue variable.

8. Create a function named clearWin() . The purpose of this function is to erase the contents of the calculator screen. The function has no parameters but should have a single command that changes the value of the calcwindow field in the calculator to an empty text string ("").

9. Save your changes to the file.

10.  Open the calculator.htm file in your Web browser. Click the different calculator buttons and verify that you can enter a mathematical expression into the calculator.

Click the backspace button ( <- ) and verify that you can erase the last character from the screen. Click the equal button (=) and verify that the calculator adds the calculated numeric value to the expression. Finally, click the Clear button and verify that all of the text is removed from the calculator screen.

Attachment:- NeededFiles.zip

Reference no: EM131777660

Questions Cloud

When it comes to the financial-credit crisis : When it comes to the financial/credit crisis that crashed in 2008, what specifically caused this affect?
What journal entries should be recorded by foley company : From the lessee's viewpoint, what kind of lease is the above agreement? From the lessor's viewpoint, what kind of lease is the above agreement
Differences in bottom-up and top-down estimating approaches : What are the differences between bottom-up and top-down estimating approaches?
Levelling within float-slack on the sensitivity of network : What is the impact of levelling within float/slack on the sensitivity of the network?
Create a function named calcexpression : Create a function named calcExpression() . The purpose of this function is to append the calculated value to the expression displayed on the calculator screen
Prepare the journal entry to record pension expense : The service cost of pension expense is $450,000. Prepare the journal entry to record pension expense for 2010
Calculate the market value of bond : Calculate the market value of this bond if investors are expecting a yield of 3% per year.
Advantages and disadvantages of relying on the property tax : Explain the advantages and disadvantages of relying on the property tax from the point of view of BOTH a local government and a taxpayer.
What is its discount-basis yield : Suppose the investment yield on 182-day T-bill is 4.79%. What is its discount-basis yield

Reviews

Write a Review

Web Project Questions & Answers

  Evaluating an ecommerce website

Create a check list that contains key point for evaluating an ecommerce website - Write a short, reflective report about website

  Gpc and runtime magic quotes

Create a script that lets you know whether Zeus or Helios has the GPC and Runtime Magic Quotes turned on or off. The output should have appropriate labels that define what output signified and should display 'ON' or 'OFF' depending on the setting.

  Creating functions through conditional operator

Use the conditional operator and the cal_days_in_month function, determine the number of days in the current month and output to browser whether it is normal month or a leap month.

  Web development projects with database

Since the vast majority of web-development projects involve a database, do you think that computational activities should be performed there, or do you think they belong in the XML page or stylesheet?

  Comparing shelf software packages

Required assistance with comparing and contrasting two main off the shelf software packages that could be implemented in an organization.

  Web based scams

Web phishing, pharming and vishing are popular web based scams. Talk about currently used tools and recommended measures to defeat this kind of attacks efficiently?

  Explanation of contextual links

The most powerful hypertext capabilities is the the contextual link. Wikipedia . com is a great example of a site that utilizes contextual links.

  How architectural and protocol changes occur

Discuss how architectural and protocol changes happen, the administrative organization that oversees the technical development of the Internet,

  Traditional approaches for training professionals

Webinars and other web conferencing techniques have proved most beneficial for the provision of affordable quality corporate training.

  Internet for business

Discuss how can a business use the Internet and give at least three examples with web links demonstrating your answer.

  It influences the behavior of organizations

Information technology influences the behavior of organizations. Name one effect of Information technology implementation and long-term usage you suppose having a positive contribution and one having a negative consequence.

  Importance of a guided navigation system

Explain the use and importance of a guided navigation system and shopping cart for a website designed for e-commerce and business purpose.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd