2014년 12월 3일 수요일

Quadratic Formula Help

I am writing an app that solves the quadratic formula using MIT App Inventor 2
My plan was to create two versions of the formula (The "+" and the "-" of -b plus or minus square root of 4ac/2a) And after doing so I was given the "The operation negate cannot accept the arguments"
I am unsure if it is the "Neg" block that is causing the issue. I have used the beta version before and assumed that "Neg" replaced the - block.

Is it the neg block that is giving me problems or is it more than that?

down vote favorite



The math blocks are described here:  http://appinventor.mit.edu/explore/ai2/support/blocks/math.html  

The - should be the neg block.

Is there a difference between       neg  get b       and   -1 *  get b  ?    There should not be, but you can test this using the DoIt debugging block.  See an example on Enis help page ...     http://twodogapps.com/?page_id=686   

Use DoIt to test for values throughout your equation.    Also, be aware the equation can be displayed differently by right clicking almost any of your Math blocks and Selecting  external inputs   or inline inputs gives you a different way of displaying your equation.

What is suspect is your  Solve button....   you do realize that whatever is the answer to the Positive_Quadform will always be what is displayed in your answer text 
The value for the Negative_Quadform is ALWAYS overwritten by the result of Positive_Quadform.

The The operation negate cannot accept the arguments" is probably do the the fact that you are asking to perform a mathematical operation  on alpha characters; that is the A, B, C.     In your equation, A, B, C, must be assigned numerical values before the equation can proceed.





you are passing components as input parameter to the procedures, this will not work
you have to pass their text properties, which is in your case A.Text, B.Text and C.Text
also make sure to validate your textboxes before calling the procedure (empty string will not work for calculations)



EDIT: Horray I got it, I ended up dividing it all by 2/a and that got the math right, and then I set the solve part for answer text boxes to set. answer text to call procedure POSITIVE_QUADFORM 
a)a-text
b) b-text
c) c-text

And then the same for the negative in a separate answer box

Thank you to all who took the time to help me with this.  


댓글 없음:

댓글 쓰기