Help with InputBox

Marco Rainaldi shared this question 2 years ago
Answered

I'm trying to get the value from an input box rounded, and then check to see if the value is accurate to the tenths place. Then change the background color of the input box to green/red depending on if the answer is correct/incorrect.

In the attached file, the script I'm trying to accomplish this with is the value "answer"

First, I don't know of a command that will round a value to the tenths place. Does one exist?

Second,

If varside=1, they are solving for the length of the side opposite the given acute angle. The value should be the length of the segment "m"

If varside=2, they are solving for the length of the hypotenuse. The value should be the length of the segment "p"

If varside=3 they are solving for the length for the side adjacent to the given acute angle. The value should be the length of the segment "n"

I'm using the following script to change the background color with no luck:

SetBackgroundColor[InputBox1,If[varside==1 && ansminusadj<0.05,"GREEN","RED"]]

SetBackgroundColor[InputBox1,If[varside==2 && ansminushyp<0.05,"GREEN","RED"]]

SetBackgroundColor[InputBox1,If[varside==3 && ansminusopp<0.05,"GREEN","RED"]]

Comments (3)

photo
1

First, I don't know of a command that will round a value to the tenths place. Does one exist?

round(a,1)

photo
1

This looks fine, check the values of the variables

SetBackgroundColor[InputBox1,If[varside==1 && ansminusadj<0.05,"GREEN","RED"]]

photo
1

What's strange is that both sides of the && statement I tested and are true in the Algebra view independently, but the combined statement is not true in the Algebra view.

Sometimes this is working correctly, and sometimes not. Not sure why the combined statement is having issues. I might have to try nested If statements to see if that clears things up.

Thanks for your help!

photo
© 2023 International GeoGebra Institute