Wednesday, June 1, 2011
Validity of equation input
Today, I had to plan out all the possible ways that the user could enter in a valid equation. The input also had to be entered with spaces and appropriate characters. I came up with 4 possibilities. For each of them, I created an isValid() method that tokenizes, parses, determines value of a, b, c and in the end, outputs if it is valid or invalid. My 4 methods were quite similar but the number of tokens for the String array varied and in some cases, b or c may be set to zero as it is not included in the input. The code was really long as there were several conditions to check for such as the operators used and whether it was a quadratic in the first place. Now that this is done, I can start working on my other methods which will display other information about the quadratic equation.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment