BarModel script is the language used in BarModeler for specifying a bar model in Math.
A bar model is described with some statements, which can be an equation statement, or a question statement.
Statement
An equation statement consists of two expressions, one on each side of the equal sign.
A question statement is an expression followed by a question mark.
For example, the following bar model has 3 equation statements and a question statement.
sandwich = drink + 0.5
pizza = 2 * drink
2 * pizza = drink + sandwich + 1.9
drink?
Expression
An expression can comprise numbers, variables, and combinations thereof using arithmetic operators such as addition ‘+’, subtraction ‘-‘, multiplication ‘*’, division ‘/’, and colon ‘:’.
A number can be an integer, a decimal, or a percent.
A variable is word, or a word followed by one or more tick signs (‘), for example tank, tank’, tank”. A variable ended with tick(s) is called a step variable, normally used in a before-after model, to indicate that the value of the original variable has changed.
Here are some examples:
apples = 10 // There are 10 apples.
oranges = apples * 2 // There are twice as many oranges as apples.
oranges = apples + 5 // There are 5 more oranges than apples.
// The number of pears is the same as the combined number of apples and oranges.
pears = apples + oranges
pears + apples + oranges = 100 // The total number pears, apples, and oranges is 100.
// 5 times of pears minus 2 times of apples is 6.
5 * pears - apples * 2 = 6
pears : apples = 4 : 5 // The ratio of pears and apples is 4 : 5.
tank' = tank + 10 // Add 10kg flour to the tank.
A bar model example
Let’s see how to solve a chicken-and-rabbits problem by “writing” a bar model. The problem is:
In a cage there are chicken and rabbits. The total number of heads is 10 and the total number of legs is 26. How many rabbits and chicken are there?
We can derive the following equations from the word problem:
chicken + rabbits = 10 // The total number of heads is 10
chicken * 2 + rabbits * 4 = 26 // The total number of legs is 26
(chicken+rabbits)? // How many rabbits and chicken are there?
And here is the bar model generated.

In this bar model, the box
represents the number of chickens and
represents the number of rabbits. The first bar shows that the number of chickens plus the number of rabbits equals 10. The second bar shows that each chicken has 2 legs and each rabbit has 4 legs, and the total number of legs is 26. Since we know that the number that
represents plus the number that
represents equals 10, we can rearrange the boxes of the second bar by putting
and
side by side, as shown in the third bar, from which we can figure out that the last two
boxes represent the number 26 – 10 – 10, which is 6. As such, a
box represents the number 3, while a
box represents the remaining 7 (10 – 3 = 7). Therefore, the answer is that there are 3 rabbits and 7 chickens.
The tool can be found here.
Leave a comment