Calculator by yaofenjin


									               Project 2: Calculator
   Write a web application that implements
    a four function calculator.

   Operations:
       Add
       Subtract
       Multiply
       Divide

   Additional functions:
       Clear
       Clear Entry
       Toggle Sign


             Software Requirements
   Let the display be capable of showing a
    maximum of 16 digits
       including decimal point if required.

   Use Decimal type for all calculations.

             Software Requirements

   Round results of operations to 16 digits.
       Results with more than 16 integer digits are
        errors. (Overflow)

   When entering a number, disable input
    after 16 digits are entered.

   Each operation (+, -, *, / ) is of the form
              Display = Acc Op Display
 Display is the contents of the Display

 Acc (“accumulator”) is the contents of
  the Display when the Operation button
  was pressed.
       Prior to entering the second operand

   Op is the operation (+, -, *, or / )
               Calculator Operation
   Pressing any Op key (+, -, *, /)
       Performs the currently pending operation
        putting the result into the display.
       Copies the new display contents into the
       Sets the specified operation as the new
        pending operation.
       Sets the state such that if a digit key or dot
        key is pressed, a new number is started in
        the display.

               Calculator Operation

   Pressing the = key has the same effects as the
    Operation keys, except it sets the pending
    operation to No Op.
   Clear sets both the display and the
    accumulator to 0.0 and sets the pending
    operation to No Op.
   Clear Entry just sets the display to 0.0
   Toggle sign reverses the sign of the display (if
    the value is nonzero.)

             Software Requirements
   If there is a decimal point in the display
    do not accept another decimal point.
       Disable “Dot” key once a decimal point has
        been entered.

                Software Requirements
   Display "ERROR" on error conditions

       Divide by Zero
       Display Overflow
            results > 16 integer digits

   All buttons become disabled except

                Implementation Tip

   The calculator requires state information.
       Accumulator
       Display state
       Pending Operation

   Use hidden fields to store state
    information with the page and restore on


   Deploy your application to your directory
    on the cis4930 web site.
   Zip your project folder and submit the
    zipped file using Blackboard Assignments.
   Put the URL for your page into the
    Blackboard submission comments box.
        Example:

   Grader should be able to view your page by copying and pasting the link.
                         Ground Rules
   You may work with one other person.
       OK to work alone if you prefer.

   If you do work as a pair
       Both members are expected to contribute.
       Both members deploy the project to their class
        web sites.
       Submit only one zipped project folder.
            Enter both names in Assignment Comments
            Enter submitter’s URL in Assignment Comments
       Other partner submits just a comment including
        both names and own URL.

                      Ground Rules

   Do not share your work with other students.
       Before or after submitting the project.
       OK to discuss the project.
       OK to look at others’ web sites with a browser.

   Do not copy any other student’s code.
       Or even look at it.

   Do not let anyone copy or examine your code.

                             Due Date

   Project is due by midnight, Wed night, Jan. 26

        No late submissions will be accepted.

End of Presentation                                  15

To top