The Lawn Mower Problem

I was able to pick up a used lawn mower for a few bucks – it starts, it cuts, and it moves.  I was actually pretty impressed with the job (5.5 hp).  I’m a little sore today from starting it so many times (40) – the grass was so high because the old one was broken that the mower stalled, but it got the job done – and quite nicely.  It got me thinking, and I put together a pretty neat little word problem that I solved iteratively, although an arguably more elegant solution is possible using algebra.

I was very careful not to mow over my 4″ diameter baby watermelons that I planted a little late this year.

My folks came for a visit, and I burned a 6 program version CD for them (including the opera program) with 3 opera arias and the 4 seasons.  The image was 660MB.

Update:  For anyone who went out and actually did the experiment, you probably realized that 11 or so times around a yard of the size of the program was not going to hack it.  It takes a lot more time.  So, I fixed the bug and rephrased the problem a little better, and I think the program runs correctly now.  Feel free to experimentally test this.

The new word problem:

01c: FORMULA: VAR1*((VAR2*2)/VAR3) VARIABLES: 3 PROB: If you drive VAR1[INT,1,25]VAR1 times per month to school, and each trip is VAR2[FLOAT,1,10]VAR2 miles each way, and your vehicle gets an average of VAR3[FLOAT,10,60]VAR3 miles per gallon, how many gallons of gas do you need in one month?

02c: FORMULA: VAR1*VAR2 VARIABLES: 2 PROB: If you eat VAR1[INT, 1,6]VAR1 slices of pizza, and each slice has VAR2[INT,100,300]VAR2 calories, how many calories do you have to burn to work off the pizza?

03c: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 2 PROB: If you have to spend VAR1[INT, 1,5]VAR1 hours taking care of your dog in order to get a movie ticket, and each session with the dog is VAR2[INT,1,30]VAR2 minutes, how many sessions with your dog do you need to do before you can go to the movies?

04c: FORMULA: VAR3*VAR2*VAR1+VAR1*VAR2 VARIABLES: 3 PROB: If there are VAR1[INT,-30,30]VAR1 percent more African Americans in US colleges than in prison, and there are VAR2[INT,10,30]VAR2 million African Americans in the US and 1 in VAR3[INT,1,25]VAR3 African Americans are currently behind bars, how many African Americans are in college the US?

05: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 3 PROB: If grass requires VAR1[FLOAT, 0,3]VAR1 inches of rain per week to survive, and 10 goats requires VAR2[FLOAT,1,3]VAR2 acres of grass to graze, how many inches of rain is required to sustain VAR3[INT,1,100]VAR3 goats?

06c: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 2 PROB: If the territory of a specific bird is VAR1[INT, 10,100]VAR1 acres and it shrinks by VAR2[FLOAT,1, 90]VAR2 %, how many acres are left in its territory?

07c: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 2 PROB: If VAR1[INT, 5000,50000]VAR1 animals are currently in US animal shelters, and animals are adopted at a rate of VAR2[FLOAT, 0, 20]VAR2 thousand per week, how many days would it take before all animals were adopted if no more animals came in?

08c: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 3 PROB: If your running time improves by VAR1[FLOAT, 0, 1]VAR1% every time you work out and you work out every other day, how many days are required before your running time drops from a VAR2[FLOAT, 12, 16]VAR2 minute mile to a VAR3[FLOAT, 2, 6]VAR3 minute mile?

09c: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 4 PROB: If you increase the room temperature by VAR1[INT, 1, 3]VAR1 degrees on the thermostat in the summer, and every degree corresponds to VAR2[INT, 50, 200]VAR2 joules/sec, how many trees will you save in VAR3[INT,1,30]VAR3 days, if one tree is the carbon-energy equivalent of VAR4[INT, 20,70]VAR4 mega-joules?

10c: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 3 PROB: If a gray whale migrates from Alaska to Mexico travelling a distance of VAR1[INT, 4500, 6500]VAR1 miles in VAR2[INT,60,120]VAR2 days to give birth to a calf, and then migrates back up the coast back to Alaska with the calf at VAR3[INT, 20, 80]VAR3 percent of its original speed, how many days will the round trip take?

11c: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 6 PROB: If VAR1[INT, 2, 50]VAR1% of your potato crop will be destroyed by bugs, and you plant VAR2[INT, 40, 500]VAR2 potato plants, each of which is expected to produce VAR3[INT, 3, 16]VAR3 potatoes that weigh VAR4[FLOAT, 0, 1]VAR4 pounds, how many days will the harvest feed VAR5[INT,1,10]VAR5 people if 50 pounds of potatoes feeds VAR6[INT,50,150]VAR6 people for a day ?

12c: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 6 PROB: A VAR1[INT, 3000, 6000]VAR1 Watt water heater is the primary source of energy consumption in a household that does not heat during the winter and only uses air conditioning in one room during the summer.  The heater consumes the energy equivalent of VAR2[INT, 82, 160]VAR2 gallons of gas per year (30% of household energy). How many round-trip medical trips of VAR3[INT,5,40]VAR3 miles each way in a VAR4[INT, 10,40]VAR4 mpg vehicle, will turning off the hot water heater for the warmest VAR5[INT,3,8]VAR5 months of the year provide in one year, assuming that the energy of heating the water during these summer months is VAR6[INT, 50, 80]VAR6 % of what it is during the winter?

13c: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 4 PROB: If you pick up VAR1[INT, 0, 12]VAR1 quarters (25 cents), VAR2[INT, 0, 20]VAR2 dimes (10 cents), VAR3[INT, 0, 20]VAR3 nickels (5 cents), and VAR4[INT, 0, 200]VAR4 pennies (1 cent), how many dollars-worth of change do you have (100 cents in a dollar)?

14c: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 7 PROB: Your local animal shelter has a euthanasia rate of VAR1[INT, 0, 12]VAR1 cats per week of those that enter, and VAR2[INT, 2, 20]VAR2 cats/day are brought into the shelter with an adoption rate of VAR3[INT, 10, 80]VAR3 percent of those that enter. VAR4[INT, 0, 120]VAR4 cats are currently at the shelter.  How many cats will there be at the shelter in VAR5[INT, 1,30]VAR5 days if the euthanasia rate is lowered by VAR6[INT, 0, 100]VAR6 % and the adoption rate is raised by VAR7[INT, 0, 100]VAR7 %.

15c: FORMULA: VAR1*VAR2*2/VAR3 VARIABLES: 8 PROB: Your stride length is VAR1[INT, 20,40]VAR1 inches.  It takes you VAR2[FLOAT, 2, 4]VAR2 minutes and VAR3[INT, 100, 400]VAR3 steps to walk around the perimeter of your yard, and VAR4[FLOAT,1,3]VAR4 times as long to push a lawn mower with a VAR5[INT, 16, 70]VAR5″ blade around the perimeter. Your first pass around the yard with the mower cuts the entire blade range leaving a VAR6[INT, 0, 5]VAR6 inch “dead area”. How many hours will it take you to mow the lawn in a circular fashion assuming that each subsequent pass around the yard cuts VAR7[INT, 60, 80]VAR7% of the blade length, and that your speed decreases by VAR8[FLOAT, 1,4]VAR8 % with each pass?

———————————————————————————————————–

#!/bin/bash

# musical_numbers.sh v.1.0 a program submitted by livedoggb on July 11/2012

# dependencies compiled random1.c, and intdiv2float.c and

# itunes directory named math_music with songs that you want to use sequentially numbered 01 …, 02 …, 03 … etc.

# It also outputs a file sommaire.out that has the statistics of your session.

mnt_path=”/mnt/sdb1/”

dir_path=”$mnt_path/for_kids/musical_numbers/”

temp_path=”/root/”

temp_file=”$temp_path/temp.out”

dir_cprog=$( echo “$mnt_path/for_kids/c_progs/” )

function round_number {

check_sign=$(echo “$answer” | sed -e “s/^\(.\).*/\1/”)

check_dig_3=$(echo “$answer” | sed -e “s/\(.*\…\)\(.\).*/\2/”)

if [ “$check_dig_3” -ge “5” ]

then

if [ “$check_sign” == “-” ]

then

answer=$(“$dir_cprog”/dec_proc “$answer” 0.01 2)

else

answer=$(“$dir_cprog”/dec_proc “$answer” 0.01 1)

fi

fi

return

}

function trim_line {

i=1

echo

#num_words=$(gawk ‘{ sum += $1 }; END { print sum }’ testline.out)

words_left=”c”

while [ “$words_left” != “” ]

do

j=$(( $i + 8 ))

words_left=$( echo “$line” | cut -d’ ‘ -f$i-$j )

echo “$words_left”

i=$(( $j + 1 ))

done

return

}

PI=3.14159

function create_geometry_problem {

num_var=$( echo “$line” | sed -e “s/^.*VARIABLES: \(.\).*/\1/” )

x=$num_var

while [ “$x” -gt “0” ]

do

grpr=$( echo VAR”$(( $num_var-$x+1 ))” )

var=$( echo “$line” | sed -e “s/^.*$grpr\(.*\)$grpr.*/\1/” )

lowint=$( echo “$var” | sed -e “s/\[\(.*\),\(.*\),\(.*\)\]/\2/” )

highint=$( echo “$var” | sed -e “s/\[\(.*\),\(.*\),\(.*\)\]/\3/” )

vartype=$( echo “$var” | sed -e “s/\[\(.*\),\(.*\),\(.*\)\]/\1/” )

if [ “$vartype” == “FLOAT” ]

then

lowint=$(( 10*$lowint ))

highint=$(( 10*highint ))

var_value=$( “$dir_cprog”/random1 $lowint $highint )

var_value=$( “$dir_cprog”/intdiv2float $var_value 10 )

else

var_value=$( “$dir_cprog”/random1 $lowint $highint )

fi

var_value=$( echo “$var_value” | sed -e “s/^0//” )

line=$( echo “$line” | sed -e “s/^.* PROB://” )

line=$( echo “$line” | sed -e “s/\(.*\)$grpr.*$grpr\(.*\)/\1 $var_value \2/” )

#     echo  $grpr :  $var, $lowint, $highint, $vartype, $var_value

#       read

x=$(($x-1))

subscript=$(($num_var-$x))

numb[$subscript]=$var_value

done

answer=”not yet available.”

#   angle=$(“$dir_cprog”/dec_proc $PI 2 4 )

#   ans=$(“$dir_cprog”/dec_proc $angle 1 9 )

#   echo “test cos = ” $ans

echo “Please round your answer to 2 decimal places.”

case “$wpnum” in

default)

answer=”not yet available.”

;;

“01”)

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

answer=$prod3

#   answer=$(“$dir_cprog”/dec_proc $( $dir_cprog/dec_proc ${numb[1]} $prod3 3 ) ${numb[3]} 4)

#   echo $answer

;;

“02”)

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 3)

answer=$prod3

;;

“03”)

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 3)

answer=$prod3

;;

“04”)

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 7)

prod3=$(“$dir_cprog”/dec_proc $prod3 $PI 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 3)

answer=$prod3

;;

“05”)

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 $PI 7)

answer=$(“$dir_cprog”/dec_proc $prod3 2 3)

#   diameter area

;;

“06”)

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 $PI 7)

answer=$prod3

#   radius area

;;

“07”)

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} 2 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 $PI 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 ${numb[1]} 3)

answer=$prod3

#   radius area

;;

“08”)

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} 2 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 ${numb[1]} 3)

answer=$prod3

;;

“09”)

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 ${numb[1]} 3)

answer=$prod3

;;

“10”)

#perimeter from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 $prod3 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 7)

prod3=$(“$dir_cprog”/dec_proc $prod3 4 3)

answer=$prod3

;;

“11”)

#area from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 $prod3 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 7)

prod3=$(“$dir_cprog”/dec_proc $prod3 $prod3 3)

answer=$prod3

;;

“12”)

#side of biggest square from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 $prod3 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 7)

answer=$prod3

;;

“13”)

#perimeter from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 4 3)

answer=$prod3

;;

“14”)

#area from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 $prod3 3)

answer=$prod3

;;

“15”)

#side of biggest square from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

answer=$prod3

;;

“16”)

#perimeter from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

radius=$(“$dir_cprog”/dec_proc $prod3 2 4)

#cos 30

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 8)

prod3=$(“$dir_cprog”/dec_proc $prod2 $radius 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 6 3)

answer=$prod3

;;

“17”)

#area from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 4)

#cos 30

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 8)

#sin 30

prod4=$(“$dir_cprog”/dec_proc $angle 1 9)

prod4=$(“$dir_cprog”/dec_proc $prod4 $prod3 3)

prod3=$(“$dir_cprog”/dec_proc $prod2 $prod3 3)

prod4=$(“$dir_cprog”/dec_proc $prod4 2 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 $prod4 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 3 3)

answer=$prod3

;;

“18”)

#side from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 4)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 8)

#cos 30

prod3=$(“$dir_cprog”/dec_proc $prod2 $prod3 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 3)

answer=$prod3

;;

“19”)

#perimeter from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

radius=$(“$dir_cprog”/dec_proc $prod3 2 4)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 30

prod3=$(“$dir_cprog”/dec_proc $radius $prod2 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 6 3)

answer=$prod3

;;

“20”)

#area from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

radius=$(“$dir_cprog”/dec_proc $prod3 2 4)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 30

prod3=$(“$dir_cprog”/dec_proc $radius $prod2 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 $radius 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 3 3)

answer=$prod3

;;

“21”)

#side from circumference

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} $PI 4)

radius=$(“$dir_cprog”/dec_proc $prod3 2 4)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 30

prod3=$(“$dir_cprog”/dec_proc $radius $prod2 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 2 3)

answer=$prod3

;;

“22”)

hyp=$(“$dir_cprog”/dec_proc ${numb[1]} 3 4)

hypo2=$(“$dir_cprog”/dec_proc $hyp 2 4)

prod1=$(“$dir_cprog”/dec_proc $hyp $hyp 3)

prod2=$(“$dir_cprog”/dec_proc $hypo2 $hypo2 3)

diff=$(“$dir_cprog”/dec_proc $prod1 $prod2 2)

answer=$(“$dir_cprog”/dec_proc $diff 1 7)

;;

“23”)

prod3=$(“$dir_cprog”/dec_proc ${numb[1]} 3 3)

answer=$prod3

#perimeter of eq. triangle of side x

;;

“24”)

;;

“25”)

angle=$(“$dir_cprog”/dec_proc $PI 3 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} $prod2 4 )

prod1=$(“$dir_cprog”/dec_proc $prod1 1 7 )

answer=$(“$dir_cprog”/dec_proc $prod1 6 3 )

;;

“26”)

angle=$(“$dir_cprog”/dec_proc $PI 3 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 60

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} $prod2 4 )

prod1=$(“$dir_cprog”/dec_proc $prod1 1 7 )

answer=$(“$dir_cprog”/dec_proc $prod1 2 3 )

;;

“27”)

angle=$(“$dir_cprog”/dec_proc $PI 3 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 60

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} $prod2 3 )

answer=$(“$dir_cprog”/dec_proc $prod1 1 7 )

;;

“28”)

angle=$(“$dir_cprog”/dec_proc $PI 3 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 60

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} ${numb[1]} 3 )

answer=$(“$dir_cprog”/dec_proc $prod1 $prod2 4 )

;;

“29”)

half_side=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4)

angle=$(“$dir_cprog”/dec_proc $PI 3 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 60

prod1=$(“$dir_cprog”/dec_proc $half_side $half_side 3 )

answer=$(“$dir_cprog”/dec_proc $prod1 $prod2 3 )

;;

“30”)

half_side=$(“$dir_cprog”/dec_proc ${numb[1]} 2 4)

angle=$(“$dir_cprog”/dec_proc $PI 3 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 60

prod1=$(“$dir_cprog”/dec_proc $half_side $half_side 3 )

answer=$(“$dir_cprog”/dec_proc $prod1 $prod2 3 )

;;

“31”)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod2 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 2 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod1 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 1 7 )

prod1=$(“$dir_cprog”/dec_proc $prod1 4 3 )

answer=$prod1

;;

“32”)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod2 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 2 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod1 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 1 7 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod1 3 )

answer=$prod1

;;

“33”)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod2 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 2 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod1 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 1 7 )

answer=$prod1

;;

“34”)

#   r=get radius of circle around triangle of perimeter x

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 8)

#cos 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4)

r=$(“$dir_cprog”/dec_proc $prod1 $prod2 4)

#   get circumference of circle of radius r

prod3=$(“$dir_cprog”/dec_proc $r $PI 3)

ci=$(“$dir_cprog”/dec_proc $prod3 2 3)

#   get perimeter of square around circle of circumference c

prod3=$(“$dir_cprog”/dec_proc $ci $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 4 3)

answer=$prod3

echo “not correct”

;;

“35”)

#   r=get radius of circle around triangle of perimeter x

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 8)

#cos 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4)

r=$(“$dir_cprog”/dec_proc $prod1 $prod2 4)

#   get circumference of circle of radius r

prod3=$(“$dir_cprog”/dec_proc $r $PI 3)

ci=$(“$dir_cprog”/dec_proc $prod3 2 3)

#   get perimeter of square around circle of circumference c

prod3=$(“$dir_cprog”/dec_proc $ci $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 4 3)

answer=$prod3

#   get length of side of square with a perimeter of $prod3

prod3=$(“$dir_cprog”/dec_proc $prod3 4 4)

# get the area of the square with a side of $prod3

prod3=$(“$dir_cprog”/dec_proc $prod3 $prod3 3)

answer=$prod3

echo “not correct”

;;

“36”)

#   r=get radius of circle around triangle of perimeter x

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 8)

#cos 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4)

r=$(“$dir_cprog”/dec_proc $prod1 $prod2 4)

#   get circumference of circle of radius r

prod3=$(“$dir_cprog”/dec_proc $r $PI 3)

ci=$(“$dir_cprog”/dec_proc $prod3 2 3)

#   get perimeter of square around circle of circumference c

prod3=$(“$dir_cprog”/dec_proc $ci $PI 4)

prod3=$(“$dir_cprog”/dec_proc $prod3 4 3)

#   get length of side of square with a perimeter of $prod3

prod3=$(“$dir_cprog”/dec_proc $prod3 4 4)

answer=$prod3

echo “not correct”

;;

“37”)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod2 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 2 3 )

answer=$prod1

;;

“38”)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod2 3 )

answer=$prod1

;;

“39”)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod2 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 2 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $PI 3 )

answer=$prod1

;;

“40”)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 10)

#tan 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod2 3 )

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod1 3 )

answer=$(“$dir_cprog”/dec_proc $prod1 $PI 3 )

;;

“41”)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 8)

#cos 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4)

prod1=$(“$dir_cprog”/dec_proc $prod1 $prod2 4)

 

answer=$(“$dir_cprog”/dec_proc $prod1 2 3 )

;;

“42”)

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 8)

#cos 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4)

answer=$(“$dir_cprog”/dec_proc $prod1 $prod2 4)

;;

“43”)

#   r=get radius of circle around triangle of perimeter x

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 8)

#cos 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4)

r=$(“$dir_cprog”/dec_proc $prod1 $prod2 4)

#   get circumference of circle of radius r

prod3=$(“$dir_cprog”/dec_proc $r $PI 3)

answer=$(“$dir_cprog”/dec_proc $prod3 2 3)

;;

“44”)

#   r=get radius of circle around triangle of perimeter x

angle=$(“$dir_cprog”/dec_proc $PI 6 4)

prod2=$(“$dir_cprog”/dec_proc $angle 1 8)

#cos 30

prod1=$(“$dir_cprog”/dec_proc ${numb[1]} 6 4)

r=$(“$dir_cprog”/dec_proc $prod1 $prod2 4)

#   get area of circle of radius r

prod3=$(“$dir_cprog”/dec_proc $r $PI 3)

prod3=$(“$dir_cprog”/dec_proc $prod3 ${numb[1]} 3)

answer=$prod3

;;

“45”)

prod3=$(“$dir_cprog”/dec_proc ${numb[3]} ${numb[1]} 2)

prod4=$(“$dir_cprog”/dec_proc ${numb[4]} ${numb[2]} 2)

slope=$(“$dir_cprog”/dec_proc $prod4 $prod3 4)

int=$(“$dir_cprog”/dec_proc $slope ${numb[1]} 3)

answer=$(“$dir_cprog”/dec_proc ${numb[2]} $int 2)

answer=$(“$dir_cprog”/dec_proc $answer $slope 4)

answer=$(“$dir_cprog”/dec_proc $answer -1 3)

;;

“46”)

prod3=$(“$dir_cprog”/dec_proc ${numb[3]} ${numb[1]} 2)

prod4=$(“$dir_cprog”/dec_proc ${numb[4]} ${numb[2]} 2)

slope=$(“$dir_cprog”/dec_proc $prod4 $prod3 4)

int=$(“$dir_cprog”/dec_proc $slope ${numb[1]} 3)

answer=$(“$dir_cprog”/dec_proc ${numb[2]} $int 2)

;;

“47”)

prod3=$(“$dir_cprog”/dec_proc ${numb[3]} ${numb[1]} 2)

prod4=$(“$dir_cprog”/dec_proc ${numb[4]} ${numb[2]} 2)

answer=$(“$dir_cprog”/dec_proc $prod4 $prod3 4)

;;

“48”)

prod3=$(“$dir_cprog”/dec_proc ${numb[4]} ${numb[2]} 2)

prod4=$(“$dir_cprog”/dec_proc ${numb[5]} ${numb[3]} 2)

slope=$(“$dir_cprog”/dec_proc $prod4 $prod3 4)

int=$(“$dir_cprog”/dec_proc $slope ${numb[2]} 3)

answer=$(“$dir_cprog”/dec_proc $slope ${numb[1]} 3)

answer=$(“$dir_cprog”/dec_proc $answer $int 1)

;;

“49”)

prod3=$(“$dir_cprog”/dec_proc ${numb[4]} ${numb[2]} 2)

prod4=$(“$dir_cprog”/dec_proc ${numb[5]} ${numb[3]} 2)

slope=$(“$dir_cprog”/dec_proc $prod4 $prod3 4)

int=$(“$dir_cprog”/dec_proc $slope ${numb[2]} 3)

if [ “$slope” == “0” ]

then

answer=${numb[2]}

else

answer=$(“$dir_cprog”/dec_proc ${numb[1]} $int 2)

answer=$(“$dir_cprog”/dec_proc $answer $slope 4)

fi

;;

esac

echo “question ” $wpnum:

#echo “$answer”

round_number

right_response=$(echo “$answer” | sed -e “s/\(.*\…\).*/\1/”)

read

}

function create_word_problem {

num_var=$( echo “$line” | sed -e “s/^.*VARIABLES: \(.\).*/\1/” )

x=$num_var

# echo $x

while [ “$x” -gt “0” ]

do

grpr=$( echo VAR”$(( $num_var-$x+1 ))” )

var=$( echo “$line” | sed -e “s/^.*$grpr\(.*\)$grpr.*/\1/” )

lowint=$( echo “$var” | sed -e “s/\[\(.*\),\(.*\),\(.*\)\]/\2/” )

highint=$( echo “$var” | sed -e “s/\[\(.*\),\(.*\),\(.*\)\]/\3/” )

vartype=$( echo “$var” | sed -e “s/\[\(.*\),\(.*\),\(.*\)\]/\1/” )

if [ “$vartype” == “FLOAT” ]

then

lowint=$(( 10*$lowint ))

highint=$(( 10*highint ))

var_value=$( “$dir_cprog”/random1 $lowint $highint )

var_value=$( “$dir_cprog”/intdiv2float $var_value 10 )

else

var_value=$( “$dir_cprog”/random1 $lowint $highint )

fi

var_value=$( echo $var_value | sed -e “s/^0//” )

line=$( echo “$line” | sed -e “s/^.* PROB://” )

line=$( echo “$line” | sed -e “s/\(.*\)$grpr.*$grpr\(.*\)/\1 $var_value \2/” )

#     echo  $grpr :  $var, $lowint, $highint, $vartype, $var_value

#       read

x=$(($x-1))

subscript=$(($num_var-$x))

numb[$subscript]=$var_value

done

echo “Please round your answer to 2 decimal places, ”

echo “or if the answer is a person or a cat, simply truncate the number ”

echo “to the integer part.”

echo

case “$wpnum” in

default)

;;

“01”)

prod3=$(“$dir_cprog”/dec_proc ${numb[2]} 2 3)

answer=$(“$dir_cprog”/dec_proc $( $dir_cprog/dec_proc ${numb[1]} $prod3 3 ) ${numb[3]} 4)

#   echo $answer

;;

“02”)

answer=$(( ${numb[1]}*${numb[2]} ))

#   echo $answer

;;

“03”)

answer=$(“$dir_cprog”/intdiv2float $((${numb[1]}*60)) ${numb[2]} )

#   echo $answer

;;

“04”)

if [ ${numb[1]} -lt 0 ]

then

line=$( echo “$line” | sed -e “s/more/fewer/” | sed -e “s/-//” )

fi

#var1=percentage of aa more in college

#VAR3*VAR2*VAR1+VAR3*VAR2

#VAR2*VAR3*(1+VAR1)

#prod3=percentage of aa in prison

#prod1=percentage of aa more in prison

prod3=$(“$dir_cprog”/intdiv2float 1 ${numb[3]} 4 )

prod1=$(“$dir_cprog”/intdiv2float ${numb[1]} 100 )

sum1=$(“$dir_cprog”/dec_proc 1 $prod1 1)

prod1=$(“$dir_cprog”/dec_proc $prod3 $sum1 3)

prod2=$(“$dir_cprog”/dec_proc $prod1 ${numb[2]} 3)

answer=$( “$dir_cprog”/dec_proc $prod2 1000000 3)

answer=$( echo $answer | sed -e “s/\..*//”)

;;

“06”)

prod3=$(“$dir_cprog”/intdiv2float ${numb[2]} 100 )

answer=$(“$dir_cprog”/dec_proc ${numb[1]} $($dir_cprog/dec_proc 1 $prod3  2) 3 )

#   echo $answer

;;

“07”)

answer=$(“$dir_cprog”/dec_proc  ${numb[2]}  1000  3)

answer=$(“$dir_cprog”/dec_proc $answer 7 4)

answer=$(“$dir_cprog”/dec_proc ${numb[1]} $answer 4 )

#   echo $answer

;;

“08”)

if [ “${numb[1]}” == 0 ]

then

break

fi

count=0

testdiff=-100

answer1=$(“$dir_cprog”/dec_proc  ${numb[1]}  100  4)

answer=$(“$dir_cprog”/dec_proc 1 $answer1 2)

test=$(“$dir_cprog”/dec_proc $answer 10 5)

answer2=$(“$dir_cprog”/dec_proc ${numb[3]} ${numb[2]} 4)

test2=$(“$dir_cprog”/dec_proc $answer2 10 5)

test3=$(“$dir_cprog”/dec_proc $test2 $test 4)

answer=$(“$dir_cprog”/dec_proc $test3 2 3)

answer=$(“$dir_cprog”/dec_proc $answer 1 2)

#   oldanswer=1

#   while [ $testdiff -lt 0 ]

#   do

#     oldanswer=$(“$dir_cprog”/dec_proc $oldanswer $answer 3)

#     answer2=$(“$dir_cprog”/dec_proc ${numb[2]} $oldanswer 3)

#    echo “test=” $test

#     diff=$(“$dir_cprog”/dec_proc ${numb[3]} $answer2 2)

#     echo “diff=” $diff

#=2*log(8.6/13.4,10)/log(1-0.003,10)

#     testdiff=$( echo $diff | sed -e “s/\..*//” )

#     count=$(($count+1))

#   done

#   answer=$( echo $(($count*2)) )

;;

“09”)

#60*var2*60*24*var3*var1/var4

const_time=$((60*60*24))

answer1=$(“$dir_cprog”/dec_proc ${numb[1]} ${numb[2]} 3)

answer1=$(“$dir_cprog”/dec_proc $answer1 ${numb[3]} 3)

answer1=$(“$dir_cprog”/dec_proc $answer1 ${numb[4]} 4)

answer1=$(“$dir_cprog”/dec_proc $const_time $answer1 3)

answer=$(“$dir_cprog”/dec_proc $answer1 1000000 4)

#   echo $answer

;;

“10”)

prod3=$(“$dir_cprog”/intdiv2float ${numb[3]} 100 )

prod3=$(“$dir_cprog”/dec_proc 1 $prod3 4)

prod4=$(“$dir_cprog”/dec_proc $prod3 1 1)

#   echo $prod3, $prod4, ${numb[2]}

answer=$(“$dir_cprog”/dec_proc ${numb[2]} $prod4 3 )

answer=$( echo “$answer” | sed -e “s/\..*//” )

#   echo $answer

;;

“11”)

num_planted=$(( ${numb[2]}*${numb[3]} ))

pounds_planted=$(“$dir_cprog”/dec_proc $num_planted ${numb[4]} 3 )

frac_left=$( “$dir_cprog”/dec_proc 100 ${numb[1]} 2 )

pounds_harv=$(“$dir_cprog”/dec_proc $frac_left $pounds_planted 3 )

pounds_harv=$( “$dir_cprog”/dec_proc $pounds_harv 100 4 )

pounds_per_person_day=$(“$dir_cprog”/dec_proc 50 ${numb[6]} 4 )

people_fed=$(“$dir_cprog”/dec_proc $pounds_harv $pounds_per_person_day 4 )

num_days=$(“$dir_cprog”/dec_proc $people_fed  ${numb[5]} 4 )

answer=$num_days

;;

“12”)

percent_of_year_wo=$(“$dir_cprog”/dec_proc ${numb[4]} 12 4 )

percent_of_year_w=$(“$dir_cprog”/dec_proc 1 $percent_of_year 2 )

frac_of_energy_use_during_summer=$( “$dir_cprog”/dec_proc ${numb[6]} 100 4 )

inv_frac=$( “$dir_cprog”/dec_proc $percent_of_year_w $frac_of_energy_use_during_summer 4 )

sum=$( “$dir_cprog”/dec_proc  $percent_of_year_wo $inv_frac 1 )

summer_rate_gallons_of_gas=$(“$dir_cprog”/dec_proc ${numb[2]} $sum 4 )

trip_miles=$(“$dir_cprog”/dec_proc ${numb[3]} 2 3 )

gall_needed_for_trips=$(“$dir_cprog”/dec_proc $trip_miles ${numb[4]} 4 )

gallons_saved=$( “$dir_cprog”/dec_proc $summer_rate_gallons_of_gas $percent_of_year_wo 3 )

number_of_trips=$(“$dir_cprog”/dec_proc $gallons_saved $gall_needed_for_trips 4 )

 

answer=$number_of_trips

;;

“13”)

quarters=$(“$dir_cprog”/dec_proc ${numb[1]} 0.25 3 )

dimes=$(“$dir_cprog”/dec_proc ${numb[2]} 0.10 3 )

nickels=$(“$dir_cprog”/dec_proc ${numb[3]} 0.05 3 )

pennies=$(“$dir_cprog”/dec_proc ${numb[4]} 0.01 3 )

sum=$(“$dir_cprog”/dec_proc $quarters $nickels 1 )

sum=$(“$dir_cprog”/dec_proc $sum $dimes 1 )

sum=$(“$dir_cprog”/dec_proc $sum $pennies 1 )

answer=$sum

;;

“14”)

er_decrease=$(“$dir_cprog”/dec_proc ${numb[6]} 100 4 )

er_per_day=$(“$dir_cprog”/dec_proc 1 $er_decrease 2 )

er_per_day=$(“$dir_cprog”/dec_proc ${numb[1]} $er_per_day 3 )

er_per_day=$(“$dir_cprog”/dec_proc $er_per_day 7 4 )

ar_increase=$(“$dir_cprog”/dec_proc ${numb[7]} 100 4 )

ar_per_day=$(“$dir_cprog”/dec_proc 1 $ar_increase 1 )

ar_entering=$(“$dir_cprog”/dec_proc ${numb[3]} 100 4 )

ar_per_day=$(“$dir_cprog”/dec_proc $ar_entering $ar_per_day 3 )

ar_per_day=$(“$dir_cprog”/dec_proc $ar_per_day  ${numb[2]} 3 )

change1=$( “$dir_cprog”/dec_proc ${numb[2]} $ar_per_day 2 )

change1=$( “$dir_cprog”/dec_proc $change1 $er_per_day 2 )

num_cats=$(“$dir_cprog”/dec_proc $change1 ${numb[5]} 3)

num_cats=$(“$dir_cprog”/dec_proc $num_cats ${numb[4]} 1)

answer=$( echo “$num_cats” | sed -e “s/\..*//” )

;;

“15”)

peri_n_inches=$( “$dir_cprog”/dec_proc ${numb[1]} ${numb[3]} 3 )

half_blade=$( “$dir_cprog”/dec_proc ${numb[5]} 2 4)

side_n_inches=$( “$dir_cprog”/dec_proc $peri_n_inches 4 4 )

dspace=$( “$dir_cprog”/dec_proc ${numb[6]} 2 3 )

mowerspace=$( “$dir_cprog”/dec_proc ${numb[5]} 2 3 )

dec1=$( “$dir_cprog”/dec_proc $mowerspace $dspace 1 )

dec1=$( “$dir_cprog”/dec_proc $dec1 2 3 )

side_pass1=$( “$dir_cprog”/dec_proc $side_n_inches $dec1 2 )

peri_pass1=$( “$dir_cprog”/dec_proc $side_pass1 4 3 )

time1=$( “$dir_cprog”/dec_proc ${numb[2]} ${numb[4]} 3 )

rate1=$( “$dir_cprog”/dec_proc $peri_pass1 $time1 4 )

#   echo “1: $peri_pass1 $time1 $rate1”

count_pass=1

totaltime=$time1

peri_pass1_ft=$( “$dir_cprog”/dec_proc $peri_pass1 12 4 )

dec1_ft=$( “$dir_cprog”/dec_proc $dec1 12 4 )

dec1_ft=$( “$dir_cprog”/dec_proc $dec1_ft 4 3 )

#   echo “$count_pass: peri = $peri_pass1_ft change = $dec1_ft rate = $rate1 time= $time1 total_time=$totaltime”

dec1=$( “$dir_cprog”/dec_proc ${numb[7]} 100 4 )

#    echo “Frac=$dec1”

dec1=$( “$dir_cprog”/dec_proc ${numb[5]} $dec1 3 )

#    echo “Decreased blade=$dec1”

dec1=$( “$dir_cprog”/dec_proc $dec1 8 3 )

#   echo “$dec1”

#   read

peri_pass2=$( “$dir_cprog”/dec_proc $peri_pass1 $dec1 2 )

old_peri_pass=$( echo “$peri_pass2” |  sed -e “s/\..*//” )

dec=$dec1

oldrate=$rate1

ratex=$( “$dir_cprog”/dec_proc ${numb[8]} 100 4 )

ratex=$( “$dir_cprog”/dec_proc 1 $ratex 2 )

count_pass=2

peri_pass2_ft=$( “$dir_cprog”/dec_proc $peri_pass2 12 4 )

dec_ft=$( “$dir_cprog”/dec_proc $dec 12 4 )

newrate=$( “$dir_cprog”/dec_proc $oldrate $ratex 3 )

newtime=$( “$dir_cprog”/dec_proc $old_peri_pass $newrate 4 )

totaltime=$( “$dir_cprog”/dec_proc $totaltime $newtime 1)

#   echo “$count_pass: peri = $peri_pass2_ft change = $dec_ft rate = $newrate time= $newtime total_time=$totaltime”

#  read

count_pass=0

while [ “$old_peri_pass” -gt 0 ]

do

count_pass=$(($count_pass + 1))

#   dec=$( “$dir_cprog”/dec_proc $dec1 $count_pass 3 )

old_peri_pass=$( “$dir_cprog”/dec_proc $peri_pass2 $dec 2 )

peri_pass2=$old_peri_pass

old_peri_pass=$( echo “$old_peri_pass” | sed -e “s/\..*//” )

oldrate=$newrate

newrate=$( “$dir_cprog”/dec_proc $oldrate $ratex 3 )

newtime=$( “$dir_cprog”/dec_proc $old_peri_pass $newrate 4 )

totaltime=$( “$dir_cprog”/dec_proc $newtime $totaltime 1)

old_peri_pass_ft=$( “$dir_cprog”/dec_proc $old_peri_pass 12 4 )

dec_ft=$( “$dir_cprog”/dec_proc $dec 12 4 )

pass=$(( $count_pass + 2 ))

#   echo “$pass: peri = $old_peri_pass_ft change = $dec_ft rate = $newrate time= $newtime total_time=$totaltime”

#     read

done

answer=$( “$dir_cprog”/dec_proc $totaltime 60 4)

;;

esac

check_for_decimals=$(echo “$answer” | sed -e “s/.*\(\.\).*/\1/”)

if [ “$check_for_decimals” == “.” ]

then

round_number

right_response=$(echo “$answer” | sed -e “s/\(.*\…\).*/\1/”)

else

right_response=$answer

fi

read

}

function read_sentence_outloud {

if [ “$read_aloud” == “y” ]

then

repeat=”y”

sp=$( echo $sound_path2/”$random_verb_num”_”$language2″_full_quotes/”$quizfact”_*.* )

echo “directory path is: ” $sp

if [ -e “$sp” ]

then

while [ “$repeat” == “y” ]

do

#< /dev/null &

shighlit=$(grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.* SENTCOMP:\(.*\).*/\1/”)

line=$shighlit

#                    trim_line

echo

echo “Press enter when you are ready to hear the sentence read aloud.”

read ready

mplayer -volume 80 “$sp”

if [ $act == “read” ]

then

trim_line

verb_guess=””

asked=$(( $asked + 1 ))

echo “Read the sentences that you heard.  Repeat? (y or n. The default is n.)”

else

verb_guess=””

asked=$(( $asked + 1 ))

echo “Write the sentences that you heard. Repeat? (y or n. The default is n.)”

fi

read repeat

if [ -e “$repeat” ]

then

repeat=”n”

fi

done

fi

fi

return

}

function show_the_sentence {

l1=$( echo $language1 | sed -e “s/kids-//” )

echo -n “The $l1 noun is: ”

echo_in_color_noun_w_gender  “random quiz line is:” $quizfact

line=$testline

verb_guess=””

asked=$(( $asked + 1 ))

if [ “$act” == “read” ]

then

trim_line

fi

while [ -e $verb_guess ]

do

l2=$( echo $language2 | sed -e “s/kids-queens//” )

echo “Enter the $l2 form of the noun (enter e to exit):”

read verb_guess

done

if [ “$verb_guess” == “e” ]

then

break

fi

echo_verb=$( grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^[0-9]*c: \(.*\)  ENG: \(.*\) (.) SENT: .*/\1/” )

if [ “$verb_guess” == “$echo_verb” ]

then

echo “Correct.”

right=$(( $right + 1 ))

average=$(( $right/$asked ))

rightverbs=$( echo $rightverbs, $echo_verb)

num_mus=$( $dir_cprog/random1 1 $num_files )

num_mus_fixed=$(echo $num_mus | sed -e “s/^0//”)

prob_time=$(( ${time_array[$num_mus_fixed]} – 20 ))

ssx=($(expr $($dir_cprog/random1 0 $prob_time)))

mplayer -msglevel all=-1 -profile gnome-mplayer -ss $ssx -endpos 20 -volume 200 /mnt/sda1/Documents\ and\ Settings/TEMP/My\ Documents/My\ Music/iTunes/iTunes\ Media/Music/$language1-$language2\ music/$num_mus*.*

else

echo “No.  The correct response is: ”  $echo_verb

echo   “random quiz line is:” $quizfact

wrongverbs=$( echo $wrongverbs, $echo_verb )

fi

echo

return

}

function read_clueword_outloud {

if [ “$read_aloud” == “y” ]

then

repeat=”y”

sp=$( echo $sound_path1/”$random_verb_num”_”$language1″_sound/”$quizfact”_nouns_”*.*” )

echo “directory path is: ” $sp

ls $sp

if [ -e $sp ]

then

while [ “$repeat” == “y” ]

do

#< /dev/null &

#                    shighlit=$(grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.* SENTCOMP:\(.*\).*/\1/”)

#                    line=$shighlit

#                    trim_line

#                    echo

#                    echo “Press enter when you are ready to hear the foreign word read aloud.”

#                    read ready

mplayer -volume 80 $sp

#                    trim_line

l1=$( echo $language1 | sed -e “s/kids-//” )

echo “Write on a separate piece of paper, and repeat aloud the $l1 word that you heard.  Repeat? (y or n. The default is n.)”

read repeat

if [ -e “$repeat” ]

then

repeat=”n”

fi

done

echo -n “The word is: ”

echo_in_color_noun_w_gender

echo

echo -n “Did you write it down correctly? (y or n)”

read $mistake

if [ -e “$mistake” ]

then

mistake=0

fi

case “$mistake” in

default)

mistake=0

;;

“y”)

mistake=0

;;

“yes”)

mistake=0

;;

“n”)

mistake=1

;;

“no”)

mistake=1

;;

esac

sum_mistakes=$(( $sum_mistakes + $(( $mistake )) ))

fi

fi

return

}

function read_englishword_outloud {

if [ “$read_aloud” == “y” ]

then

repeat=”y”

sp=$( echo “$sound_path2″/”$random_verb_num”_”$language2″_sound/”$quizfact”_”*.*” )

echo “directory path is: ” $sp

if [ -e $sp ]

then

while [ “$repeat” == “y” ]

do

#< /dev/null &

#                    shighlit=$(grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.* SENTCOMP:\(.*\).*/\1/”)

#                    line=$shighlit

#                    trim_line

#                    echo

l1=$( echo $language1 | sed -e “s/kids-//” )

l2=$( echo $language2 | sed -e “s/kids-queens//” )

#                    echo “Press enter when you are ready to hear the $l2 word read aloud.”

#                    read ready

mplayer -volume 80 $sp

#                    trim_line

echo -n “The word in the $l1 language you are studying is: ”

echo_in_color_noun_w_gender

echo

 

echo “Write on a separate piece of paper and repeat aloud the $l2 word that you heard.  Repeat? (y or n. The default is n.)”

read repeat

if [ -e “$repeat” ]

then

repeat=”n”

fi

done

l1=$( echo $language1 | sed -e “s/kids-//” )

#              echo -n “The word in the $l1 language you are studying is: ”

#              echo_in_color_noun_w_gender

echo

echo -n “The word in $l2 you are studying is: ”

engnoun=$( grep “^$correctquizfact:” “$dir_txt_path2″/$fn*.txt | sed -e “s/^.*c:\(.*\)  ENG:.*/\1/” )

echo $engnoun

echo

echo -n “Did you write it down correctly? (y or n)”

read $mistake

if [ -e “$mistake” ]

then

mistake=0

fi

case “mistake” in

default)

mistake=0

;;

“y”)

mistake=0

;;

“yes”)

mistake=0

;;

“n”)

mistake=1

;;

“no”)

mistake=1

;;

esac

sum_mistakes=$(( $sum_mistakes + $(( $mistake )) ))

fi

fi

return

}

function echo_in_color_noun_w_gender {

case $language in

default)

LANG=es_ES.UTF-8

;;

“german”)

LANG=de_DE.UTF-8

;;

“greek”)

LANG=el_GR.UTF-8

;;

“hebrew”)

LANG=he_IL.UTF-8

revnoun=$( echo $noun | rev_str )

echo “reversed noun ” $revnoun

noun=$revnoun

;;

“norwegian”)

LANG=nn_NO

;;

esac

color=$( grep “^$correctquizfact:” $dir_txt_path1/$fn*.txt | sed -e “s/^[0-9]*c:\(.*\)ENG: \(.*\) *(\(.\)) *SENT:.*/\3/” )

case “$color” in

“m”)

echo -e ‘\E[47;34m'”33[1m$noun33[0m”

;;

“f”)

echo -e ‘\E[47;31m'”33[1m$noun33[0m”

;;

“n”)#0CF82B

echo -e ‘\E[47;42m'”33[1m$noun33[0m”

;;

esac

LANG=es_ES.UTF-8

tput sgr0

return

}

function select_language2 {

lang_picked=”notpicked”

while [ $lang_picked == “notpicked” ]

do

echo “Available reader languages are:”

echo  1. English

echo

echo -n “Enter a number:”

read lang_num

if [ “$lang_num” -gt 6 ]

then

echo “Language not yet available.  Pick another one. ”

fi

case “$lang_num” in

1)

language=”kids-queensenglish”

lang_picked=”picked”

LANG=es_ES.UTF-8

;;

default)

language=”kids-queensenglish”

lang_picked=”picked”

LANG=es_ES.UTF-8

;;

esac

done

language2=$language

l2=$( echo $language2 | sed -e “s/kids-queens//” )

echo “This is a map of where ” $l2 “is spoken in the world.”

viewnior “$dir_path”/maps/”$l2″.png < /dev/null &

return

}

function select_language1 {

lang_picked=”notpicked”

while [ $lang_picked == “notpicked” ]

do

echo “Available exercises are:”

echo  1. Addition

echo  2. Subtraction

echo  3. Multiplication

echo  4. Division

echo  5. Fractions

echo  6. Geometry

echo  7. Polynomials

echo  8. Word Problems

echo

echo -n “Enter a number:”

read lang_num

# if [ “$lang_num” -gt 6 ]

#    then

#      echo “Language not yet available.  Pick another one. ”

# fi

 

case “$lang_num” in

1)

language=”addition”

lang_picked=”picked”

;;

2)

language=”subtraction”

lang_picked=”picked”

;;

3)

language=”multiplication”

lang_picked=”picked”

;;

4)

language=”division”

lang_picked=”picked”

;;

5)

language=”fractions”

lang_picked=”picked”

;;

6)

language=”decimals”

lang_picked=”picked”

LANG=es_ES.UTF-8

;;

7)

language=”polynomials”

lang_picked=”picked”

;;

8)

language=”word problems”

lang_picked=”picked”

;;

default)

language=”addition”

lang_picked=”picked”

;;

esac

language1=$language

# l1=$( echo $language1 | sed -e “s/kids-//” )

# echo “This is a map of where ” $l1 “is spoken in the world.”

# viewnior “$dir_path”/maps/”$l1”.png < /dev/null &

done

return

}

function set_paths {

#clue language is lang1

#reading language is lang2

 

lang2=$( echo “$language2″testnouns)

tvf2=$( echo “$lang2”)

dir_txt_path2=$( echo “$dir_path”/$tvf2/$lang2 )

tvs2=$( echo “$tvf2″_sound )

lang1=$( echo “$language1”-“$lang2”)

tvf1=$( echo “$lang1”)

dir_txt_path1=$( echo “$dir_path”/$lang2/$tvf1/ )

tvs1=$( echo “$tvf1″_sound )

sound_path1=$( echo “$dir_path”/$tvs2/”$language1″_sound_nouns/ )

sound_path2=$( echo “$dir_path”/$tvs2/”$language2″_sound_nouns/ )

#echo “Clue working language path is: ” $dir_txt_path1

#ls $dir_txt_path1

#echo “Reading working language path is: ” $dir_txt_path2

#ls $dir_txt_path2

#echo “Clue working sound path is: ” $sound_path1

#ls $sound_path1

#echo “Reading working sound path is: ” $sound_path2

#ls $sound_path2

return

}

clear

# select_language2

select_language1

#set_paths

if [ -e “$temp_path/sommaire.out” ]

then

rm “$temp_path/sommaire.out”

fi

#rm $dir_path/hyper-tense-files_used.out

sum_fautes=0

if [ -e “$dir_path” ]

then

echo “directory path passed.”

else

echo “directory path not valid.  Your USB device might be mounted under a different name.  Reset path on line 11 and start over.”

read

fi

echo “Please wait for a few minutes while the system sets up the music database.”

if [ -e “$temp_path/$language-time2.out” ]

then

echo “The program has found a time file.”

echo “1. Use this file.”

echo “2. Make a new time file. Choose 2 if you have changed the music.”

echo “Please choose:  (If you aren’t sure, choose 2.  The default is 2.)”

read choice

else

echo “0” > “$temp_path/$language-time2.out”

choice=2

fi

if [ -e $choice ]

then

choice=2

fi

case $choice in

1)

echo “Using the old file.”

;;

2)

echo “Making another file.  This will take a few minutes.  Please be patient.”

if [ -e “$temp_path/$language-time2.out” ]

then

rm “$temp_path/$language-time2.out”

fi

echo “0” > “$temp_path/$language-time2.out”

mplayer -msglevel all=-1 -profile gnome-mplayer -ss 0 -endpos 1 -volume 0 /mnt/sda1/Documents\ and\ Settings/TEMP/My\ Documents/My\ Music/iTunes/iTunes\ Media/Music/math_music/*.* | tee “$temp_path/temp_file” | grep “^A: ” | sed -e ‘s/^A: .* of \([0-9]*\).* .*/\1/g’ >> “$temp_path/$language-time2.out”

;;

esac

time_array=($(cat “$temp_path/$language-time2.out”))

i=1

num_files=$(expr $(grep -c . “$temp_path/$language-time2.out”))

i=0

while [ $i -lt $num_files ]

do

echo “$i. ${time_array[$i]}”

i=$(( $i + 1 ))

done

num_files=$(( $num_files – 1 ))

echo “num_files=” $num_files

echo

if [ “$lang_num” == “8” -o “$lang_num” == “6” ]

then

if [ “$lang_num” == “8” ]

then

echo “Doing word problems.”

else

echo “Doing geometry problems.”

fi

else

echo “Several options are possible.  Please choose a level (enter a number between 1 and 6).”

echo

echo “Level 1.  0-10 numbers (only positive).”

echo “Level 2.  0-100 numbers (only positive).”

echo “Level 3.  0-1000 numbers (only positive).”

echo “Level 4.  ?”

echo “Level 5.  0-10 numbers (positive and negative).”

echo “Level 6.  0-100 numbers (positive and negative).”

echo “Level 7.  0-1000 numbers (positive and negative).”

echo “Level 8.  Numbers with decimals (positive and negative).”

echo

echo -n “Level?”

read choice

#echo  “With oral reading? Choose y or n.  Default is n.”

#read read_aloud

if [ -e $read_aloud ]

then

read_aloud=”n”

fi

flag=”integer”

case “$choice” in

1)

echo “Level 1.”

echo “0-10 numbers”

rnmin=0

rnmax=10

;;

2)

echo “Level 2.”

echo “0-100 numbers”

rnmin=0

rnmax=100

;;

3)

echo “Level 3.”

echo “0-1000 numbers”

rnmin=0

rnmax=1000

;;

4)

echo “Level 4”

echo “numbers with decimals.”

rnmin=-10000

rnmax=10000

flag=”decimal”

;;

5)

echo “Level 5.”

echo “0 -10 numbers with negatives”

rnmin=-10

rnmax=10

;;

6)

echo “Level 6.”

echo “0-100 numbers with negatives”

rnmin=-100

rnmax=100

;;

7)

echo “Level 7.”

echo “0-1000 numbers with negatives”

rnmin=-1000

rnmax=1000

;;

8)

echo “Level 8.”

echo “Decimals with negatives.”

rnmin=-10000

rnmax=10000

flag=”decimal”

;;

esac

fi

#echo “All information derives from .txt files in the folder ” $dir_txt_path

language_primer=$( echo $dir_txt_path2 )

c=””

right=0

asked=0

rightverbs=””

wrongverbs=””

average=0

verb_guess=””

#num_vfiles=$(expr $(ls -1  $dir_txt_path2/*.txt | grep -c . ))

hours_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\1/”| sed “s/0\([0-9]\)/\1/” )

min_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\2/”| sed “s/0\([0-9]\)/\1/” )

sec_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\3/”| sed “s/0\([0-9]\)/\1/” )

num_files=$(expr $(grep -c . “$temp_path/$language-time2.out”))

mistakes=0

while [ -e $c ]

do

exp1=$( “$dir_cprog”/random1 1 4 )

ex1=$( echo $exp1 | sed -e “s/^0//” )

exp2=$( “$dir_cprog”/random1 1 4 )

ex2=$( echo $exp2 | sed -e “s/^0//” )

if [ “$flag” == “integer” ]

then

ex1=0

ex2=0

else

exp1=1

exp2=1

#       echo -n “ex1 is” $ex1 “,”

while [ $ex1 -ge 0 ]

do

exp1=$(( 10 * $exp1 ))

ex1=$(( $ex1 – 1 ))

done

#        echo “exponent 1 is” $exp1

#        echo -n “ex2 is” $ex2 “,”

while [ $ex2 -ge 0 ]

do

exp2=$(( 10 * $exp2 ))

ex2=$(( $ex2 – 1 ))

done

#        echo “exponent 2 is” $exp2

fi

case “$lang_num” in

1)

random_num1=$( “$dir_cprog”/random1 $rnmin $rnmax)

rn1c=$( echo $random_num1 | sed -e “s/^0//” )

random_num2=$( “$dir_cprog”/random1 $rnmin $rnmax )

rn2c=$( echo $random_num2 | sed -e “s/^0//” )

if [ $flag == “integer” ]

then

echo -n “$rn1c + $rn2c =”

read response

right_response=$(( $rn1c + $rn2c ))

else

rn1f=$( “$dir_cprog”/intdiv2float $rn1c $exp1 )

rn2f=$( “$dir_cprog”/intdiv2float $rn2c $exp2 )

echo -n “$rn1f + $rn2f =”

read response

right_response=$( “$dir_cprog”/dec_proc $rn1f $rn2f 1 )

fi

language=”addition”

lang_picked=”picked”

;;

2)

random_num1=$( “$dir_cprog”/random1 $rnmin $rnmax)

rn1c=$( echo $random_num1 | sed -e “s/^0//” )

random_num2=$( “$dir_cprog”/random1 $rnmin $rn1c)

rn2c=$( echo $random_num2 | sed -e “s/^0//” )

if [ $flag == “integer” ]

then

echo -n “$rn1c – $rn2c =”

read response

right_response=$(( $rn1c – $rn2c ))

else

rn1f=$( “$dir_cprog”/intdiv2float $rn1c $exp1 )

rn2f=$( “$dir_cprog”/intdiv2float $rn2c $exp2 )

echo -n “$rn1f – $rn2f =”

read response

right_response=$( “$dir_cprog”/dec_proc $rn1f $rn2f 2 )

fi

language=”subtraction”

lang_picked=”picked”

;;

3)

random_num1=$( “$dir_cprog”/random1 $rnmin $rnmax)

rn1c=$( echo $random_num1 | sed -e “s/^0//” )

random_num2=$( “$dir_cprog”/random1 $rnmin $rnmax)

rn2c=$( echo $random_num2 | sed -e “s/^0//” )

if [ $flag == “integer” ]

then

echo -n “$rn1c x $rn2c =”

read response

right_response=$(( $rn1c * $rn2c ))

else

rn1f=$( “$dir_cprog”/intdiv2float $rn1c $exp1 )

rn2f=$( “$dir_cprog”/intdiv2float $rn2c $exp2 )

echo -n “$rn1f x $rn2f =”

read response

right_response=$( “$dir_cprog”/dec_proc $rn1f $rn2f 3 )

fi

language=”multiplication”

lang_picked=”picked”

;;

4)

random_num1=$( “$dir_cprog”/random1 $rnmin $rnmax)

rn1c=$( echo $random_num1 | sed -e “s/^0//” )

random_num2=$( “$dir_cprog”/random1 1 $rnmax)

rn2c=$( echo $random_num2 | sed -e “s/^0//” )

random_num3=$( “$dir_cprog”/random1 0 $rnmax)

rn3c=$( echo $random_num3 | sed -e “s/^0//” )

rn1c=$(( $rn1c*$rn2c ))

#echo “multiplier is: ” $rn1c “,” $rn2c

if [ $flag == “integer” ]

then

echo -n “$rn1c / $rn2c =”

read response

right_response=$(( $rn1c / $rn2c ))

else

rn1f=$( “$dir_cprog”/intdiv2float $rn1c $exp1 )

rn2f=$( “$dir_cprog”/intdiv2float $rn2c $exp2 )

echo -n “$rn1f / $rn2f =”

read response

right_response=$( “$dir_cprog”/dec_proc $rn1f $rn2f 4 )

fi

language=”division”

lang_picked=”picked”

;;

5)

language=”fractions”

lang_picked=”picked”

;;

6)

language=”geometry”

lang_picked=”picked”

num_lines=$( grep -c “^.*: FORMULA” “$dir_path/geometry_problems” )

c=””

response=””

# while [ “$response” == “” ]

#        do

echo “Enter e to exit.”

wpnum=$( “$dir_cprog”/random1 1 $num_lines )

wpnc=$( echo “$wpnum”c )

line=$( grep “^$wpnc:” “$dir_path/geometry_problems” )

testline=$( echo “$line” | sed -e “s/^.*\(c\): FORMULA.*/\1/” )

if [ “$testline” == “c” ]

then

create_geometry_problem

trim_line

read response

echo “response is ” $response

fi

;;

7)

language=”polynomials”

lang_picked=”picked”

;;

8)

language=”word problems”

lang_picked=”picked”

# a=$( /mnt/sdb1/for_kids/c_progs/intdiv2float 3 365 )

#    echo $a

num_lines=$( grep -c “^.*: FORMULA” “$dir_path/word_problems” )

c=””

response=””

# while [ “$response” == “” ]

#        do

echo “Enter e to exit.”

wpnum=$( “$dir_cprog”/random1 1 $num_lines )

wpnc=$( echo “$wpnum”c )

line=$( grep “^$wpnc:” “$dir_path/word_problems” )

testline=$( echo “$line” | sed -e “s/^.*\(c\): FORMULA.*/\1/” )

if [ “$testline” == “c” ]

then

create_word_problem

trim_line

read response

echo “response is ” $response

fi

#     done

;;

default)

language=”addition”

lang_picked=”picked”

;;

esac

if [ “$response” == “e” ]

then

break;

fi

if [ “$response” == “$right_response” ]

then

right=$(($right + 1 ))

num_mus=$( “$dir_cprog”/random1 1 $num_files )

num_mus_fixed=$(echo $num_mus | sed -e “s/^0//”)

prob_time=$(( ${time_array[$num_mus_fixed]} – 20 ))

ssx=($(expr $($dir_cprog/random1 0 $prob_time)))

mplayer -msglevel all=-1 -profile gnome-mplayer -ss $ssx -endpos 20 -volume 200 /mnt/sda1/Documents\ and\ Settings/TEMP/My\ Documents/My\ Music/iTunes/iTunes\ Media/Music/math_music/$num_mus*.*

else

mistakes=$(($mistakes + 1 ))

fi

asked=$(( $asked + 1 ))

echo “The right response is: ” $right_response

aver_right=$( $dir_cprog/intdiv2float $right $asked | sed -e “s/\([0-9]*\…\).*/\1/” )

echo $right “/” $asked ” correct.  Batting average:” $aver_right “Mistakes: ” $mistakes

echo “Please wait while I look for another question… Enter e to exit.”

done

hours_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\1/”| sed “s/0\([0-9]\)/\1/” )

min_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\2/”| sed “s/0\([0-9]\)/\1/” )

sec_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\3/”| sed “s/0\([0-9]\)/\1/” )

hours_diff=$(( $hours_end – $hours_bgn ))

min_diff=$(( $min_end – $min_bgn ))

sec_diff=$(( $sec_end – $sec_bgn ))

midnight=12

if [ $hours_diff -lt 0 ]

then

hours_diff=$(( $(( $midnight – $hours_bgn )) + $hours_end ))

# fix hour change if it happens at midnight or noon,

fi

time_of_ans=$(( $hours_diff * 60 + $min_diff ))

aver_time=$( $dir_cprog/intdiv2float $time_of_ans $((asked – 1)) | sed -e “s/\([0-9]*\…\).*/\1/” )

echo “You worked ” $time_of_ans “minutes for an average of: ” $aver_time “minutes per question, and a sum of ” $(($asked – 1)) “questions with ” $mistakes ” mistakes.” | tee >> $temp_path/sommaire.out

echo “The correct answers (” $right “):” $rightverbs  | tee >>$temp_path/sommaire.out

wrong=$(( $asked -1 – $right ))

echo “The incorrect answers (” $wrong “):” $wrongverbs | tee >>$temp_path/sommaire.out

#num_entries=$(grep “^[0-9]*c:” $dir_txt_path/*.txt | grep -c .)

#echo “The database had ” $num_entries “entries.” | tee >>$temp_path/sommaire.out

echo “Your percentage: ” $aver_right | tee >>$temp_path/sommaire.out

cat $temp_path/sommaire.out

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s