How to get GeoGebra 5 Classic to identify if a string contains more than one term ?

Aritmometer shared this question 2 months ago
Answered

How to get GeoGebra 5 Classic to identify if a string contains more than one term ?

The solution has to work for the following two scenarios.

A student is going to write one or more letters in a input-field. I then need to get GeoGebra to check if the expression contains more than one term in case it is going to be multiplied as there have to be written brackets around them.

But I also need it to check if a reduced formula with fractions and more than one term in the top or bottom of the fraction on one of its sides, contains more than one term. I need it also here to get GeoGebra to write brackets around it when students choose to multiply its sites with a letter.

Comments (3)

photo
1

I should probably mention that I have thought about checking the string for more than one “+” or “-“ or a combination of those by splitting the string up into smaller pieces with the length of 1 sign and get GeoGebra to count the times they appear. Which I know how to do.

But this solution can’t totally be used when a formula can contain a fraction with more than one term in the top or bottom of the fraction as this check-method also would count the terms in the fraction.

photo
1

Please gives some examples of good and bad input

photo
1

I have found a way but it may not be the easiest one...

Split the text-string in smaller parts with the length of 1.

Find out how many “\” there are in the list and find there positions.

Get the first 5 elements of the list after the first “\”, that will indicate if there is a fraction or a square root or n. root after it.

Then find out how many “{“ there are and then find the position of the last one.

Take the whole part out and insert it in a new list.

Create a new list from the original list where the part is left out.

etc. ...

Count the number of “+” and “-“ in the last list and add 1. to get the number of terms.

© 2020 International GeoGebra Institute