# Mark Fraction answer as correct in Math Input

Hello, I am trying to mark an answer as correct in Math Input if a student enters a fraction such as 3/4. This is so confusing for me.

1 Like

Hello,

I created 3 screens to check that someone inputs 3/4 as their answer. You can see them here:

I left notes in the CL to explain what is happening. Fractions are a bit tricky to check against, as you check against numericValue and currently with â€śnumerUsageâ€ť to identify how many times someone input a certain character. Hope this helps!

2 Likes

Thanks for your reply. So for one answer they have to put in the equation: y=-1/3x+1 and the other answer is -1/3 (2 different problems). Both of these are negative and repeating decimals. Not able to get it to work yet.

1 Like

`countNumberUsage` doesnâ€™t take negative numbers. So,

`correct: countNumberUsage(input.latex,1)=1 and countNumberUsage(input.latex,3)=1`
would be correct for either -1/3 or 1/3 (or 3x+1 for that matter).

also checking for numericValue within a particular decimal range will handle positive versus negative.

So I the answer they have to put in now is y = 1/3x+1
How to I code it so the program will check their equation?

A simple way. This will accept any form of the line.

In the input CL:

``````myLine=xyLine(this.latex)
m=myLine.slope
b=myLine.yIntercept
correct: m<0.34 and m>0.32 and b=1
``````

If you specifically want that form, youâ€™ll need to add something a little more complicated:

``````rhs=parseEquation(this.latex).rhs
checkNumbers=countNumberUsage(rhs,1)=2 and countNumberUsage(rhs,3)=1
``````

then, add `and checkNumbers` to the end of `correct` above. The second line of code above checks that the number 1 occurs twice (in the fraction and the y-intercept here), and 3 occurs once (in the fraction here).

It worked. Thank you so much!