(*libLIST=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson/TRSMREL/libLIST.m"]<>"\n";
libNAMES=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson/TRSMREL/libNAMES.m"]<>"\n";
libIO=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson/TRSMREL/libIO.m"]<>"\n";
libERR=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson/TRSMREL/libERR.m"]<>"\n";
libGUI=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson/TRSMREL/libGUI.m"]<>"\n";
libGraphics=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson/TRSMREL/libGraphics.m"]<>"\n";
libML=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson/TRSMREL/libML.m"]<>"\n";
libMISC=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson/TRSMREL/libMISC.m"]<>"\n";*)

libLIST=ReadString["C:/mathematica/Work/lossofgenerality/TRSM/10.3/libLIST.m"]<>"\n";
libNAMES=ReadString["C:/mathematica/Work/lossofgenerality/TRSM/10.3/libNAMES.m"]<>"\n";
libIO=ReadString["C:/mathematica/Work/lossofgenerality/TRSM/10.3/libIO.m"]<>"\n";
libERR=ReadString["C:/mathematica/Work/lossofgenerality/TRSM/10.3/libERR.m"]<>"\n";
libGUI=ReadString["C:/mathematica/Work/lossofgenerality/TRSM/10.3/libGUI.m"]<>"\n";
libGraphics=ReadString["C:/mathematica/Work/lossofgenerality/TRSM/10.3/libGraphics.m"]<>"\n";
libML=ReadString["C:/mathematica/Work/lossofgenerality/TRSM/10.3/libML.m"]<>"\n";
libMISC=ReadString["C:/mathematica/Work/lossofgenerality/TRSM/10.3/libMISC.m"]<>"\n";

data="\n"<>"textfghjkl:="<>ToString[{

(* top question*)

{"Column[{fghjkl"<>".ToString[\"A sum of $#a is invested in a bank account where interest is calculuated at #b% per annum.\n If the sum is invested for #c years, what amount will it come to at the end of this \"<>IntegerName[ToExpression[#c]]<>\"  year period if interest is calculated as: \"]"<>","<>"ToString[\"\",TraditionalForm]}]"},

(*a*)
(* pay attention to the formating below for IntegerName *)
{"Column[{ToString[\"FGHJKLabc) simple interest? \",TraditionalForm]"<>","<>"ToString[\" \"]"<>"}]"},


(*b*)
{"Column[{ToString[\"FGHJKLabc) compound interest? \",TraditionalForm]"<>","<>"ToString[\" \"]"<>"}]"},

(*c*)
{"Column[{ToString[\"FGHJKLabc) compound quarterly? \",TraditionalForm]"<>","<>"ToString[\" \"]"<>"}]"},


(*d*)
{"Column[{ToString[\"FGHJKLabc)What length of time will it take $#a to amount to $#d if interest is calculated as compound interest? Round your answer to two decmial places.  \",TraditionalForm]"<>","<>"ToString[\" \"]"<>"}]"} 

},InputForm]<>";\n ";

variation1=data<>ToString[Hold[Module[{a,b,c,d,e,f,g,h,i,j,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,kk, vars,text,list,sol, parta, partb, partc, partd,question,b2},


question=qRandList[textfghjkl[[1]]];

text=qRandList[textfghjkl[[2]]];

b=ToString@RandomInteger[{4,12}];
c=ToString@RandomInteger[{8,18}];
a= ToString@RandomInteger[1000];
d=ToString@(ToExpression[a]*RandomInteger[{3,7}]);
vars={a,b,c,d};

question=StringReplace[question, {"#a"->a,"#b"->b, "#c"->c,"#d"->d}];

sol=ToString[ToExpression[a]*(1+ToExpression[b]*0.01*ToExpression[c]),TraditionalForm];

parta={StringReplace[text, {"#a"->a,"#b"->b, "#c"->c,"#d"->d}],vars,sol} ;


(* part b*)
text=qRandList[textfghjkl[[3]]];

vars={a,b,c,d};
sol=ToString[ToExpression[a]*(((1+ToExpression[b]*0.01))^(ToExpression[c])),TraditionalForm];
partb={StringReplace[text, {"#a"->a,"#b"->b, "#c"->c,"#d"->d}],vars,sol} ;

(* part c*)
text=qRandList[textfghjkl[[4]]];

vars={a,b,c,d};
sol=ToString[ToExpression[a]*(((1+(ToExpression[b]*0.01)/4))^(ToExpression[c]*4)),TraditionalForm];
partc={StringReplace[text, {"#a"->a,"#b"->b, "#c"->c,"#d"->d}],vars,sol} ;



(* part d*)
text=qRandList[textfghjkl[[5]]];

vars={a,b,c,d};
sol=ToString[Log[ToExpression[d]/ToExpression[a]]/Log[1+ToExpression[b]*0.01],TraditionalForm];
partd={StringReplace[text, {"#a"->a,"#b"->b, "#c"->c,"#d"->d}],vars,sol} ;


{{question,parta[[1]], partb[[1]],partc[[1]],partd[[1]]},{parta[[2]], partb[[2]],partc[[2]],partd[[2]]}, {parta[[3]], partb[[3]],partc[[3]],partd[[3]]}}



(* it has to be InputForm or ToExpression fails *)
]],InputForm]<>"\n ";


solution1=data<>ToString[Hold[Module[{a,b,c,d,e,f,g,h,i,j,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,kk, text,list,sola,solb,solc,sold, body={},vars=ertyuiop,options=ERTYUIOP, varsa, varsb, varsc,varsd,b2,b3},



varsa=vars[[1]];
varsb=vars[[2]];
varsc=vars[[3]];
varsd=vars[[4]];

{a,b,c,d}=varsa;



body={
{{a,b,c,d}=varsa;
sola=ToString[ToExpression[a]*(1+ToExpression[b]*0.01*ToExpression[c]),TraditionalForm];
solb=ToString[ToExpression[a]*(((1+ToExpression[b]*0.01))^(ToExpression[c])),TraditionalForm];
solc=ToString[ToExpression[a]*(((1+(ToExpression[b]*0.01)/4))^(ToExpression[c]*4)),TraditionalForm];
sold=ToString[Log[ToExpression[d]/ToExpression[a]]/Log[1+ToExpression[b]*0.01],TraditionalForm];

options[[1]]<>":\nA = "<>a<>"[1 + "<>ToString[ToExpression[b]*0.01,TraditionalForm]<>"("<>c<>")]"<>"\nA = "<>a<>"("<>ToString[1 + ToExpression[b]*0.01*ToExpression[c],TraditionalForm]<>")"<>"\nA = $"<>ToString[qTrunc6[ToExpression[sola]],TraditionalForm]<>"\n",

(*b*)
{a,b,c,d}=varsb;
options[[2]]<>":\nA = "<>a<>"(1 + "<>ToString[ToExpression[b]*0.01,TraditionalForm]<>ToString[((")")^(ToExpression[c])),TraditionalForm]<>
"\nA = "<>a<>"("<>ToString[SetPrecision[(((1+ToExpression[b]*0.01))^(ToExpression[c])),7],TraditionalForm]<>")"<>
"\nA = $"<>ToString[qTrunc6[ToExpression[solb]],TraditionalForm]<>"\n",


(*c*)
{a,b,c,d}=varsc;

options[[3]]<>":\nA = "<>a<>"(1 + "<>ToString[((ToString[ToExpression[b]*0.01,TraditionalForm])/("4")),TraditionalForm]<>ToString[((")")^(ToString[ToExpression[c],TraditionalForm]<>"(4)")),TraditionalForm]<>
"\nA = "<>a<>"("<>ToString[SetPrecision[(((1+((ToExpression[b]*0.01)/4)))^(ToExpression[c]*4)),7],TraditionalForm]<>")"<>
"\nA = $"<>ToString[qTrunc6[ToExpression[solc]],TraditionalForm]<>"\n",

(*d*)

{a,b,c,d}=varsd;

options[[4]]<>":\n"<>d<>" = "<>a<>"(1 + "<>ToString[ToExpression[b]*0.01,TraditionalForm]<>ToString[((")")^("n")),TraditionalForm]<>
"\n"<>ToString[ToExpression[d]/ToExpression[a],TraditionalForm]<>" = "<>ToString[((ToString[1+ToExpression[b]*0.01,TraditionalForm])^("n")),TraditionalForm]<>
"\nn = "<>ToString["log"<>ToString[ToExpression[d]/ToExpression[a],TraditionalForm]/"log"<>ToString[1+ToExpression[b]*0.01,TraditionalForm],TraditionalForm]
<>"\nn = "<>ToString[qTrunc6[ToExpression[sold]],TraditionalForm](*ToString[SetPrecision[ToExpression[sold],4],TraditionalForm]*)
},
{Null ,Null, Null,Null}
};

Panel[Grid[Transpose[body]]]

]],InputForm]<>"\n ";


hint1=ToString[Hold[Module[{aa,bb,cc,dd,ee, ff, gg, hh, ii, jj, text,list,sol, body={},vars=ertyuiop,options=ERTYUIOP},


body={ 
{ToString[Column[{
"A = final amount/future value\nP = Present value\nr = interest rate(as a decimal)\nn = time\n",
options[[1]]<>": \n"<>"A = P(1 + rn)"<>"\n",
options[[2]]<>": \n"<>"A = P(1 + r)^n"<>"\n", 
options[[3]]<>": \n"<>"A = P(1 + (r/4))^(4  n)"<>"\n", 
options[[4]]<>": \n"<>"A = P(1 + r)^n\nn = ((log (number))/(log (base)))"
}],TraditionalForm]
},
{Null (*,Null, Null,Null,Null*)}
};

Panel[Grid[Transpose[body]]]

]],InputForm]<>"\n ";

data1="\n"<>"textfghjkl:="<>ToString[{

(* top question*)

{"Column[{fghjkl"<>".ToString[\"An investment of $#a was made #b years ago at a fixed annual rate of interest on a @a. Its maturity value was $#d. Find the fixed rate of annual compound interest on the @a. Round your answer to the nearest percent. \"]"<>","<>"ToString[\"\",TraditionalForm]}]"}



},InputForm]<>";\n ";

data2="listfghjkl:="<>


ToString[{"bond","stock","mutual fund","treasury bill"

},InputForm]<>";\n ";

data=ToString[{data1, data2}, InputForm];


variation2=ToExpression[data][[1]]<>ToExpression[data][[2]]<>ToString[Hold[Module[{a,b,c,d,e,f,g,h,i,j,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,kk, vars,text,list,sol,sol2,x, parta, partb, partc, partd,question,b2},


question=qRandList[textfghjkl[[1]]];

aa=RandomChoice@listfghjkl;
a=ToString@RandomInteger[{40000,60000}];
b=ToString@RandomInteger[{5,15}];
d=ToString@(RandomInteger[{20000,35000}]+ToExpression[a]);

c= ToString@RandomInteger[1000];
vars={a,b,c,d};

question=StringReplace[question, {"@a"->aa,"#a"->a,"#b"->b, "#c"->c,"#d"->d}];
sol2=NSolve[x>0 && ToExpression[d]==ToExpression[a]*(((1+x))^(ToExpression[b])),x,Reals];
sol=If[(x/.sol2[[1]])*100<10,ToString[IntegerPart[ToExpression[ToString[SetPrecision[(x/.sol2[[1]])*100,1]]]],TraditionalForm],ToString[IntegerPart[ToExpression[ToString[SetPrecision[(x/.sol2[[1]])*100,2]]]],TraditionalForm]];


{{question," "},{vars}, {sol}}



(* it has to be InputForm or ToExpression fails *)
]],InputForm]<>"\n ";


solution2=ToExpression[data][[1]]<>ToExpression[data][[2]]<>ToString[Hold[Module[{a,b,c,d,e,f,g,h,i,j,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,kk, text,list,sol,sol2,sol3,x, body={},vars=ertyuiop,options=ERTYUIOP, varsa, varsb, varsc,varsd,b2,b3},




{a,b,c,d}=vars[[1]];

sol2=NSolve[x>0 && ToExpression[d]==ToExpression[a]*(((1+x))^(ToExpression[b])),x,Reals];
sol=If[(x/.sol2[[1]])*100<10,ToString[IntegerPart[ToExpression[ToString[SetPrecision[(x/.sol2[[1]])*100,1]]]],TraditionalForm],ToString[IntegerPart[ToExpression[ToString[SetPrecision[(x/.sol2[[1]])*100,2]]]],TraditionalForm]];

body={
{
d <>" = "<>a<>ToString[(("(1 + r)")^(ToExpression[b])),TraditionalForm],   

ToString[SetPrecision[ToExpression[d]/ToExpression[a],7],TraditionalForm]<>" = "<>ToString[(("(1 + r)")^(ToExpression[b])),TraditionalForm], 
ToString[((SetPrecision[ToExpression[d]/ToExpression[a],7])^("("<>ToString[(("1")/b),TraditionalForm]<>")")),TraditionalForm]<>" = "<>ToString["1 + r",TraditionalForm],
If[(x/.sol2[[1]])<0.1,ToString[1+ToExpression[ToString[SetPrecision[(x/.sol2[[1]]),5],TraditionalForm]],TraditionalForm],ToString[1+ToExpression[ToString[(x/.sol2[[1]]),TraditionalForm]],TraditionalForm]]<>" = "<>ToString["1 + r",TraditionalForm],
"r = "<>If[(x/.sol2[[1]])<0.1,ToString[SetPrecision[(x/.sol2[[1]]),5],TraditionalForm],ToString[(x/.sol2[[1]]),TraditionalForm]],
"r = "<>sol<>"%"

},
{Null ,Null, Null,Null,Null,Null}
};

Panel[Grid[Transpose[body]]]

]],InputForm]<>"\n ";


hint2=ToString[Hold[Module[{aa,bb,cc,dd,ee, ff, gg, hh, ii, jj, text,list,sol, body={},vars=ertyuiop,options=ERTYUIOP},


body={ 
{"A = final amount/future value\nP = Present value\nr = interest rate(as a decimal)\nn = time\n","A = P(1 + r)^n"},
{Null ,Null}
};

Panel[Grid[Transpose[body]]]

]],InputForm]<>"\n ";

data1="\n"<>"textfghjkl:="<>ToString[{

(* top question*)

{"Column[{fghjkl"<>".ToString[\"How much do I need to invest today, at #a% per year, compounded daily in a savings account in order to have $#b at the end of #c years @a? \"]"<>","<>"ToString[\"\",TraditionalForm]}]"}



},InputForm]<>";\n ";

data2="listfghjkl:="<>


ToString[{"for my child's weeding","to buy a car for my child","for my child's tuition for his university education"

},InputForm]<>";\n ";

data=ToString[{data1, data2}, InputForm];


variation3=ToExpression[data][[1]]<>ToExpression[data][[2]]<>ToString[Hold[Module[{a,b,c,d,e,f,g,h,i,j,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,kk, vars,text,list,sol,sol2,x, parta, partb, partc, partd,question,b2},


question=qRandList[textfghjkl[[1]]];

aa=RandomChoice[listfghjkl];

a=ToString@RandomInteger[{5,10}];
b=ToString@RandomInteger[{40000,60000}];
c=ToString@RandomInteger[{15,25}];
d= ToString/@RandomInteger[1000];
vars={a,b,c,d};

question=StringReplace[question, {"@a"->aa,"#a"->a,"#b"->b, "#c"->c,"#d"->d}];
sol2=NSolve[x>0 && ToExpression[b]==x*((1+((ToExpression[a]*0.01)/365))^(365*ToExpression[c])),x,Reals];
sol=ToString[SetPrecision[x/.sol2[[1]],20],TraditionalForm];


{{question," "},{vars}, {sol}}



(* it has to be InputForm or ToExpression fails *)
]],InputForm]<>"\n ";


solution3=ToExpression[data][[1]]<>ToExpression[data][[2]]<>ToString[Hold[Module[{a,b,c,d,e,f,g,h,i,j,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,kk, text,list,sol,sol2,x, body={},vars=ertyuiop,options=ERTYUIOP, varsa, varsb, varsc,varsd,b2,b3},




{a,b,c,d}=vars[[1]];
sol2=NSolve[x>0 && ToExpression[b]==x*((1+((ToExpression[a]*0.01)/365))^(365*ToExpression[c])),x,Reals];
sol=ToString[SetPrecision[x/.sol2[[1]],20],TraditionalForm];


body={
{b<>" = P(1 + "<>ToString[((ToExpression[a]*0.01)/("365")),TraditionalForm]<>ToString[((")")^("365("<>c<>")")),TraditionalForm],

b<>" = P(1 + "<>ToString[((ToExpression[a]*0.01)/("365")),TraditionalForm]<>ToString[((")")^(ToString[ToExpression[c]*365,TraditionalForm])),TraditionalForm],

b<>" = "<>ToString[SetPrecision[(((1 + ((ToExpression[a]*0.01)/365)))^(ToExpression[c]*365)),7],TraditionalForm]<>" P ",   

"P = "<>ToString[qTrunc8[ToExpression[sol],2],TraditionalForm]
},
{Null ,Null, Null,Null}
};

Panel[Grid[Transpose[body]]]

]],InputForm]<>"\n ";


hint3=ToString[Hold[Module[{aa,bb,cc,dd,ee, ff, gg, hh, ii, jj, text,list,sol, body={},vars=ertyuiop,options=ERTYUIOP},


body={ 
{"A = final amount/future value\nP = Present value\nr = interest rate(as a decimal)\nn = time\n","A = P(1 + (r/365))^(365  n)"},
{Null ,Null}
};

Panel[Grid[Transpose[body]]]

]],InputForm]<>"\n ";

data1="\n"<>"textfghjkl:="<>ToString[{

(* top question*)

{"Column[{fghjkl"<>".ToString[\"And asset is known to appreciate in value by #a% (simple interest) per year. It was purchases on Mar 1,2009. If it was worth $#b at the end of 2009, how much was it worth when it was purchased? (note: there are 306 days from March 1st to Dec 31.) \"]"<>","<>"ToString[\"\",TraditionalForm]}]"}



},InputForm]<>";\n ";

data2="listfghjkl:="<>


ToString[{""

},InputForm]<>";\n ";

data=ToString[{data1, data2}, InputForm];


variation4=ToExpression[data][[1]]<>ToExpression[data][[2]]<>ToString[Hold[Module[{a,b,c,d,e,f,g,h,i,j,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,kk, vars,text,list,sol, parta, partb, partc, partd,question,b2},


question=qRandList[textfghjkl[[1]]];

a=ToString@(RandomInteger[{7,15}]);
b=ToString@(RandomInteger[{20000,40000}]);

{c,d}= ToString/@{RandomInteger[1],RandomInteger[1]};
vars={a,b,c,d};

question=StringReplace[question, {"#a"->a,"#b"->b, "#c"->c,"#d"->d}];


sol=ToString[SetPrecision[ToExpression[b]/(1  + ToExpression[a]*0.01*((306/365))),30],TraditionalForm];


{{question," "},{vars}, {sol}}



(* it has to be InputForm or ToExpression fails *)
]],InputForm]<>"\n ";


solution4=ToExpression[data][[1]]<>ToExpression[data][[2]]<>ToString[Hold[Module[{a,b,c,d,e,f,g,h,i,j,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,kk, text,list,sol, body={},vars=ertyuiop,options=ERTYUIOP, varsa, varsb, varsc,varsd,b2,b3},




{a,b,c,d}=vars[[1]];

sol=ToString[SetPrecision[ToExpression[b]/(1  + ToExpression[a]*0.01*((306/365))),30],TraditionalForm];

body={
{b<>" = P[1 + "<>ToString[ToExpression[a]*0.01,TraditionalForm]<>"((306/365))]",

b<>" = "<>ToString[SetPrecision[1  + ToExpression[a]*0.01*((306/365)),7],TraditionalForm]<>" P",

"P = "<>ToString[qTrunc8[ToExpression[sol],2],TraditionalForm]
},
{Null ,Null, Null}
};

Panel[Grid[Transpose[body]]]

]],InputForm]<>"\n ";


hint4=ToString[Hold[Module[{aa,bb,cc,dd,ee, ff, gg, hh, ii, jj, text,list,sol, body={},vars=ertyuiop,options=ERTYUIOP},


body={ 
{"A = final amount/future value\nP = Present value\nr = interest rate(as a decimal)\nn = time\n","A = P(1 + rn)"},
{Null ,Null}
};

Panel[Grid[Transpose[body]]]

]],InputForm]<>"\n ";

CONFIGURATION AREA

ToExpression@libGUI;
ToExpression@libIO;


proc1=ToString[{ToString[Hold[Module[{},"level"]],InputForm],variation1,hint1,solution1},InputForm]<>";\n";
proc2=ToString[{ToString[Hold[Module[{},"level"]],InputForm],variation2,hint2,solution2},InputForm]<>";\n";
proc3=ToString[{ToString[Hold[Module[{},"level"]],InputForm],variation3,hint3,solution3},InputForm]<>";\n";
proc4=ToString[{ToString[Hold[Module[{},"level"]],InputForm],variation4,hint4,solution4},InputForm]<>";\n";


panelsMIX={ 
StringReplace[qpanelMulti,{"pn0"->ToString[1],"proc0"->proc1,"libs"->(libLIST<>"\n"<>libNAMES<>"\n"<>libIO<>"\n"<>libERR<>"\n"<>libMISC<>"\n"<>libGUI),"err0"->"{err2,err2,err2,err2}", "inputsize0"->"{8,8,8,8}","level00"->ToString[{1,1,{}}],"max0"->"3","mult0"->"4","diag00"->"0","IO00"->"qClick"}],

StringReplace[qpanelMulti,{"pn0"->ToString[2],"proc0"->proc2,"libs"->(libLIST<>"\n"<>libNAMES<>"\n"<>libIO<>"\n"<>libERR<>"\n"<>libMISC<>"\n"<>libGUI),"err0"->"{errNO}", "inputsize0"->"{8}","level00"->ToString[{1,1,{}}],"max0"->"3","mult0"->"1","diag00"->"0","IO00"->"qClick"}],

StringReplace[qpanelMulti,{"pn0"->ToString[3],"proc0"->proc3,"libs"->(libLIST<>"\n"<>libNAMES<>"\n"<>libIO<>"\n"<>libERR<>"\n"<>libMISC<>"\n"<>libGUI),"err0"->"{err41}", "inputsize0"->"{8}","level00"->ToString[{1,1,{}}],"max0"->"3","mult0"->"1","diag00"->"0","IO00"->"qClick"}],

StringReplace[qpanelMulti,{"pn0"->ToString[4],"proc0"->proc4,"libs"->(libLIST<>"\n"<>libNAMES<>"\n"<>libIO<>"\n"<>libERR<>"\n"<>libMISC<>"\n"<>libGUI),"err0"->"{err41}", "inputsize0"->"{8}","level00"->ToString[{1,1,{}}],"max0"->"3","mult0"->"1","diag00"->"0","IO00"->"qClick"}]

};

CDF Area

CDFDeploy[ToFileName[{$UserDocumentsDirectory},"TRSM_FINMATH_PRAC.cdf"],Column[Table[ReleaseHold[ToExpression[panelsMIX[[i]]]],{i,1,Length[panelsMIX]}]],
"Method"->"Standalone"];

TEST AREA

Column[Table[ReleaseHold[ToExpression[panelsMIX[[i]]]],{i,1,Length[panelsMIX]}]]