Calculator Processing

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Calculator Processing - Presentation Transcript

    1. Start Fresh
      Download from
      TPITVB.blogspot.com
      2
      1
    2. Start fresh
      Start VS 2005 and Create a new project: Calculator_IT1C_xx
      Choose appropriate directory and remember its path
      Exit VS 2005
      Unzip start_cal.zip: Form1.vb and Form1.Designer.vb
      Use File explorer to replace the two newly created project files in Calculator_IT1C_xx
    3. ButtonSqrt_Click
      Double click on the button for Sqrt to generate the ButtonSqrt_Click subroutine
      Copy the codes from ButtonEqual_Click
      Modify the following line to use Math.Sqrt
      total = total + x
      total = Math.Sqrt(x)
    4. ButtonPercent_Click
      Double click on the button for % to generate the ButtonPercent_Click subroutine
      Copy the codes from ButtonEqual_Click
      Modify the following line to use Math.Sqrt
      total = total + x
      total = x / 100
    5. Dot
      Private Sub ButtonDot_Click
      ‘ Copy the codes from Button0
      ‘ Replace “0” with “.”
      Dim existingString As String = TextBox1.Text
      If existingString <> "" Then
      TextBox1.Text = existingString & "0"
      End If
      End Sub
      “.”
    6. Testing
      1.5 OK
      0.5 NG => How?
    7. Dot
      Private Sub ButtonDot_Click
      ‘ Add else condition
      ‘ to add “0.”
      Dim existingString As String = TextBox1.Text
      If existingString <> "" Then
      TextBox1.Text = existingString & “.”
      End If
      End Sub
      Else
      TextBox1.Text = existingString & “0.”
      End If
      End Sub
    8. Testing
      1.5 OK
      0.5 OK
      1.5.5. => should not allow – How?
    9. How to stop “1.5.5.”?
      We need to use a global variable to track if “.” has been set
      Then add additional codes in ButtonDot to check this variable
    10. Dot
      Global variable:
      Public Class Form1
      Dim isDotted As Boolean = False
    11. Dot
      Private Sub ButtonDot_Click
      ‘ Add Condition to check for isDotted
      Dim existingString As String = TextBox1.Text
      If existingString <> "" Then
      TextBox1.Text = existingString & “.”
      Else
      TextBox1.Text = existingString & “0.”
      End If
      End Sub
      If isDotted = False Then
      isDotted= True ‘ Set isDotted to True
      End If
      End Sub
    12. Testing
      1.5 OK
      0.5 OK
      1.5.5. OK
      1.5 Clear 1.5 => NG - How?
    13. Dot
      Private Sub ButtonClear_Click
      :
      :
      ‘ Reset isDotted to False
      isDotted = False
      End Sub
    14. Testing
      1.5 OK
      0.5 OK
      1.5.5. OK
      1.5 Clear 1.5 OK
      1.5 + 1.5 => NG – How?
    15. Dot
      Private Sub ButtonPlus_Click
      :
      :
      ‘ Reset isDotted to False
      isDotted = False
      End Sub
    16. Testing
      1.5 OK
      0.5 OK
      1.5.5. OK
      1.5 Clear 1.5 OK
      1.5 + 1.5 OK
      Anymore cases?
    17. Minus, Multiply and Divide
      Before we proceed to add the processing for Minus, Multiply and Divide,
      we need to modify the current processing for Plus and Equal
    18. Modify Plus and Equal
      Private Sub ButtonPlus_Click
      :
      :
      total = total + x
      :
      End Sub
      total = x ‘ Now, Plus can only be ‘ pressed once.
    19. Modify Plus and Equal
      Global variable:
      Public Class Form1
      Dim whatFunction As String = “None”
    20. Modify Plus and Equal
      Private Sub ButtonPlus_Click
      :
      :
      whatFunction = “Plus”
      End Sub
    21. Modify Plus and Equal
      Private Sub ButtonEqual_Click
      :
      :
      total = total + x
      :
      End Sub
      Select Case whatFunction
      Case “Plus”
      total = total + x
      End Select
      Case “Minus”
    22. Add Minus, Multiply and Divide
      Complete the processing for minus, multiply and divide.
      Take care of divide by zero error with if then else statement
      Do testingand debugging to take care of other errors
    SlideShare Zeitgeist 2009

    + puahhlsspuahhlss Nominate

    custom

    45 views, 0 favs, 1 embeds more stats

    Logic for the calculator development.

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 45
      • 43 on SlideShare
      • 2 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds
    • 2 views on http://tpitvb.blogspot.com

    more

    All embeds
    • 2 views on http://tpitvb.blogspot.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories