Docstoc

Calculator

Document Sample
Calculator Powered By Docstoc
					               Project 2: Calculator
   Write a web application that implements
    a four function calculator.

   Operations:
       Add
       Subtract
       Multiply
       Divide


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




                                   2
          Example




http://rollinsturner.net/calculator


                                      3
             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.




                                               4
             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.




                                                       5
                          Operations
   Each operation (+, -, *, / ) is of the form
              Display = Acc Op Display
Where
 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 / )
                                               6
               Calculator Operation
   Pressing any Op key (+, -, *, /)
       Performs the currently pending operation
        putting the result into the display.
       Copies the new display contents into the
        accumulator.
       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.

                                                         7
               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.)

                                                       8
             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.




                                                     9
                Software Requirements
   Display "ERROR" on error conditions

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


   All buttons become disabled except
    Clear.


                                           10
                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
    postback.


                                             11
                              Submission

   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:
            http://cis4930wp.eng.usf.edu/wpusr40

   Grader should be able to view your page by copying and pasting the link.
                                                                               12
                         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.



                                                            13
                      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.



                                                          14
                             Due Date

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

        No late submissions will be accepted.




End of Presentation                                  15

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:4
posted:9/23/2011
language:English
pages:15