Number keys (1-9), 0 keys, positive and negative conversions, decimal point, square root take the reciprocal, CE, C, backspace, subtraction, equals
Number keys (1-9):
- Press the string on the screen to add a numeric character
- If the first digit is pressed after the operator, the screen is first emptied and then
Judgment: There is no operator in front, if pressed, before the other number
0 Keys:
- Pressing the 0 key, as long as the screen is not 0, will add a 0 character after the string
- When there is only one 0 o'clock on the screen, no matter how the press is a 0
Judging: Is not zero on the screen
Decimal point:
- If the previous is a 0, press the decimal point, and then press the operator, the screen shows 0 (by operator colleague, the number of redundant parts removed, as equals)
- After pressing, add a decimal character after the string
- If there are already decimal points, you can no longer enter the decimal point until you press the operator or equal sign or CE or BACKSPACE to delete the decimal point and start entering the next number.
Judging: Whether the decimal point is pressed before, and when the operator is pressed, the point status should go back to the state that can be pressed
Positive and negative conversions:
- If it is a number plus a decimal point, the decimal points do not disappear after positive or negative conversion
- If there is only 0 on the screen, press this key without changing
- If there is nothing on the screen other than the minus sign, press this key to precede the string with a minus sign
If there is a minus sign on the screen, remove the minus sign
Judgment: Press after as long as not only 0, all directly add the burden of the number can be, do not need to consider the first, so judging whether the screen is 0; whether the first character on the screen is a minus sign
Square:
- A square operation of the preceding number is pressed.
- The current face already has another subtraction, pressing after the square operation of the previous number to display the square result, and then press equals, to display the total result
- When you press a number and a subtraction, and then press this key to display the square result of the first number, and then press equals, display the total result
Judge:
Prescribing
1. When pressed, the preceding number is
2. The current face already has another subtraction, press after the first number of the first operation to show the root result, and then press equals, only show the total results
3. When you press a number and a subtraction, and then press this key to display the root result of the first number, and then press equals, show the total result
Take the countdown:
1. When pressed, the last digit entered will be counted.
2. The current face already has another subtraction, after pressing the previous number to take the reciprocal operation to display the reciprocal result, and then press Equals, to show the total result
3. When you press a number and a subtraction, then press this key to display the countdown result of the first digit, and then press equals to display the total result
Ce:
- The number of recently entered zeros is zeroed when pressed
No need to judge
C: Press All to zero, all back to the initial state
No need to judge
BACKSPACE: When pressed, the last character of the string on the screen will be erased.
No need to judge
Subtraction
- When pressed, an operation is recorded, the first number on the screen is constant, and if the operator is pressed directly, the first number is the default zero
- If the previous operation has already been done and is equal, then when the operator is pressed, the result of the last operation is used as the first number, and the result of the first operation is still displayed on the screen.
- If there is a previous operation but not equal to, then when the operator is pressed, the result of the first operation is displayed on the screen and is used as the first digit of the next operation.
Judgment: 1. Need judge record operation mode; 2.
Equals:
- If the number and operator are pressed before, the number on the screen is calculated as the second number, the result of the operation is displayed, and if you continue to equal, the second number is always the second number, and the operation
- If you press a number or number and a decimal point, the number is equal to the original, and if the last character is 0 or a decimal point, it will be completely removed (loop)
- Press the equals sign, then press the number key to start a new operation
Android Calculator---ideas and calculator function comb (unfinished)