Post by jarychk on Jul 17, 2024 9:36:50 GMT
Two Part Mixture Exercise, typical for beginning algebra students -
but they normally do the work all on paper.
So common a form of exercise that it can be computerized; but the form is also very practical.
This little program takes user input of amount of blend, solution, or mixture in whatever units; concentration of the low, the high, and the result AS PERCENTS concentration;
and when ready, user clicks button to get results. How much to mix of each of the two separate concentrations.
but they normally do the work all on paper.
So common a form of exercise that it can be computerized; but the form is also very practical.
This little program takes user input of amount of blend, solution, or mixture in whatever units; concentration of the low, the high, and the result AS PERCENTS concentration;
and when ready, user clicks button to get results. How much to mix of each of the two separate concentrations.
'VARIABLES
Q=0
baj=0
alta=0
R=0
x=0 'output and to be computed
nomainwin
WindowWidth = 550+30
WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #main.statictext1, "Two solutions will be mixed to make", 30, 61, 224, 25
textbox #main.quant, 270, 56, 80, 25
statictext #main.statictext3, "units of", 374, 61, 64, 20
textbox #main.result, 30, 91, 72, 25
statictext #main.statictext5, "% concentration result.", 118, 96, 144, 20
statictext #main.statictext6, "The lower concentration, percent is ", 30, 131, 208, 20
textbox #main.low, 254, 126, 100, 25
statictext #main.statictext8, "The higher concentration percent is ", 30, 166, 208, 20
textbox #main.high, 254, 161, 100, 25
statictext #main.statictext10, "How much of each solution needs to be mixed?", 30, 206, 144, 20
button #main.button11, "HOW MUCH EACH?", [howmuch], UL, 334, 201, 160, 25
statictext #main.answ, "ANSWER HERE", 22, 271, 472+30, 50+15
open "two part mixture (percents)" for window as #main
print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
print #main.answ,"!font ms_sans 12 bold"
wait
[quit.main]
Close #main
END
[howmuch] 'Perform action for the button named 'button11'
'Insert your own code here
print #main.quant,"!contents? Q"
print #main.low,"!contents? baj"
print #main.high,"!contents? alta"
print #main.result,"!contents? R"
'
if Q<=0 or baj<=0 or alta<=0 or R<=0 then
notice "something wrong in given data"
wait
end if
if R<baj or R>alta then
notice "something illogical here"
wait
end if
'perform computation for x
numer=R-baj
denom=alta-baj
x=Q*(numer/denom)
'put a limitation on excess accuracy
let x$=using("##.###",x)
let x=val(x$)
'put into a variable to be displayed
answ$=str$(Q-x);" units of ";str$(baj);" % solution and ";str$(x);" units of the ";str$(alta);" % solution."
'show in the answ ext. statictext
print #main.answ,answ$
wait