среда, 4 ноября 2015 г.

MIS 574 Week 3 iLab The Calculator (Part 3)

BUY MIS 574 Week 3 iLab The Calculator (Part 3)

iLab 3 of 6: The Calculator (Part 3)
Last week, we created the buildNumber( ) procedure that allowed us to take button click events and convert them to numbers saved to the calculator's display label. We need to modify the buildNumber( ) procedure to allow the display to be reset and display a new number after the user has pressed an Operator button.
The blnStartNewNumber variable tells us when the user entry should start a new number or add to an existing number. Whenever a user presses an Operator button, the value of blnStartNewNumber will be set to true, and the next number pressed by the user will clear the display and begin a new number; otherwise, the number will be concatenated to the number in the display.
To complete the logic for the buildNumber( ) procedure, we must add an if-statement that tests blnStartNewNumber and takes the appropriate action to either start a new number or add to the current number.
We check to see if the operation was a percent or a square root. If it is, we do something different. If not, we need to discover the previous operation. Our global variable "strOp" tells us that. If it is clear, then this is the first number of our operation, and we can simply store it as our running total in the variable dblTotal. If it is not "clear", then it is either "add", "subtract", "multiply", or "divide" and we need to perform the proper operation.

Комментариев нет:

Отправить комментарий