(*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";

data1="\n"<>"textfghjkl:="<>ToString[
{"Column[{fghjkl"<>".ToString[\"Find the original price of a @a that eventually sold for $#a after it had been reduced by #b%. \"]"<>","<>"ToString[\"\",TraditionalForm]}]"},InputForm]<>";\n ";

data2="listfghjkl:="<>


ToString[{"suit","television", "stereo system", "bicycle"


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

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

variation1=ToExpression[data][[1]]<>ToExpression[data][[2]]<>ToString[Hold[Module[{aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,a,b,c, vars,text,list,sol,question},


text=qRandList[textfghjkl];

aa=RandomChoice@listfghjkl;

(*{a,b}=ToString/@{100,200};*)
c= ToString@(RandomInteger[{10,99}]*10);
b=ToString@(RandomInteger[{1,9}]*10);
a=ToString@(ToExpression[c]*((100-ToExpression[b])/100));
vars={aa,a,b,c};
sol=c;
(*ToString[N[(ToExpression[a]*((100-ToExpression[b])/100))],TraditionalForm];*)



question=StringReplace[text, {"@a"->aa,"#a"->a,"#b"->b}];

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

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


solution1=data1<>data2<>ToString[Hold[Module[{aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,a,b,c, text,list,sol, body={},vars=ertyuiop},



{aa,a,b,c}=vars[[1]];
sol=c;(*ToString[N[(ToExpression[a]/((100-ToExpression[b])/100))],TraditionalForm];*)

body={
{ToString[tv[{"Method1",
"Percent decrease"<>"\n"<>a<>" = P - P("<>b<>"%)"<>
"\n"<>a<>" = "<>ToString[SetPrecision[1-(ToExpression[b]/100),1],TraditionalForm]<>" P"<>
"\nP = $"<>sol,
"Method2",
"Percent decrease"<>"\n"<>a<>" = P(100% - "<>b<>" %)"<>
"\n"<>a<>" = "<>ToString[SetPrecision[1-(ToExpression[b]/100),1],TraditionalForm]<>" P"<>
"\nP = $"<>sol,
"Method3",
"Triangle Method\n"<>
ToString[tri1["P", "(100% - "<>b<>"%)", a],TraditionalForm]<>
"\n                        ⇓"<>
"\n P ="<>ToString[(a/(" (100% - "<>b<>"%)")),TraditionalForm]<>
"\n P ="<>ToString[a/ToString[SetPrecision[1-(ToExpression[b]/100),1],TraditionalForm],TraditionalForm]<>
"\nP = $"<>sol
}],TraditionalForm]
(*,
"Method1",
"Percent decrease"<>"\nF = "<>a<>" - "<>a<>"("<>b<>"%)",
"F = "<>a<>" - "<>ToString[ToExpression[a]*ToExpression[b]/100,TraditionalForm],
"F = "<>sol,
"\nMethod2",
"Percent decrease"<>"\nF = "<>a<>"(100% - "<>b<>" %)",
"F = "<>"("<>ToString[100-ToExpression[b],TraditionalForm]<>"%)"<>a,
"F = "<>"("<>ToString[SetPrecision[(100-ToExpression[b])/100,1],TraditionalForm]<>")"<>a,
"F = "<>sol,
"\nMethod3",
"Triangle Method",
ToString[tri1[a, "(100% - "<>b<>"%)", "F"],TraditionalForm],
"⇓",
"F = "<>a<>" × (100% - "<>b<>"%)",
"F = "<>"("<>ToString[100-ToExpression[b],TraditionalForm]<>"%)"<>a,
"F = "<>"("<>ToString[SetPrecision[(100-ToExpression[b])/100,1],TraditionalForm]<>")"<>a,
"F = "<>sol*)},
{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},


body={
{"Let F be the final amount",
"Let P be the original/initial amount",
(*"%↑ means percent increase",*)
"%↓ means percent decrease\n",
"Solve by",

ToString[tv[{"Method 1",
"F = P - P(%↓)    Percent decrease",
"Method 2",
"F = P(100% - %↓)    Percent decrease",
"Method 3",
"Triangle Method\n"<>ToString[tri1["P", "(100% - %↓)", "F"],TraditionalForm]}],TraditionalForm]
(*"\nMethod1",
(*"F = P + P(%↑)    Percent increase\n*)"F = P - P(%↓)    Percent decrease",
"\nMethod2",
(*"F = P(100% + %↑)    Percent increase\n*)"F = P(100% - %↓)    Percent decrease",
"\nMethod3",
"Triangle Method",
ToString[tri1["P", "(100% - %↓)", "F"],TraditionalForm],
"⇓",
"F = P × (100% - %↓)"*)
},
{Null,Null ,Null, Null,Null}
};

Panel[Grid[Transpose[body]]]

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

(* TODO: add more variations *)
data="\n"<>"textfghjkl:="<>ToString[{

(* question *)
{"ToString[\"fghjkl. An investment made together by @a and @b increased in value to $#c by the end of the year. This represented a gain of #d% on the original investment.\" ]"},


(* a *)
{"Column[{ToString[\"FGHJKLabc)Find the amount they invested together at the beginning of the year. \",TraditionalForm]}]"},

(*b *)
{"ToString[\"FGHJKLabc)If @a invested $#e less than @b, how much did @c invest? \",TraditionalForm]"}

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

variation2=data<>ToString[Hold[Module[{p,a,b,c,d,e,f,g,h,i,j,i0,j0,i1,i2,i3,j1,j2,j3,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,jj0,jj1,jj2,jj3, vars,text,list,sol, sol1,parta, partb, partc, partd,parte,question,y,x,missing,tmp,m,z},


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

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

{aa,bb}= RandomSample[qNamesList, 2][[All,1]];
g=RandomChoice[{1,2}];
Which[g==1,cc=aa,g==2,cc=bb];
(* ANNA add the correct formulas *)
(*{c,d,e}=ToString/@{100,100,100};*)

d=ToString@(RandomInteger[{7,17}]);
a=ToString@(RandomInteger[{170,200}]*100);
c=ToString@(IntegerPart[ToExpression[a]*(1+(ToExpression[d]*0.01))]);
e=ToString@(RandomInteger[{400,499}]*2);

question=StringReplace[question, {"@a"->aa,"@b"->bb,"@c"->cc,"#c"->c,"#d"->d,"#e"->e}];

vars={aa,bb,c,d,e,a};
(*Anna fix sol *)
sol=a;(*ToString@(SetPrecision[ToExpression[c]/(1+(ToExpression[d]/100)),10]);*)

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


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


vars={aa,bb,c,d,e};
(*Anna fix sol *)
(*sol1=Solve[x+y==SetPrecision[ToExpression[c]/(1+(ToExpression[d]/100)),7] && x==y-ToExpression[e],{x,y},Reals];
(*sol=ToString[{Max[x/.sol1],Max[y/.sol1]},InputForm];*)*)
y=IntegerPart[( IntegerPart[ToExpression[c]/(1+(ToExpression[d]/100))]+ToExpression[e])/2];
x =IntegerPart[(IntegerPart[ToExpression[c]/(1+(ToExpression[d]/100))] -ToExpression[e])/2 ];
(*sol=ToString[{ToExpression[x],ToExpression[ y]},InputForm];*)
If[g==1,
sol=ToString[x,TraditionalForm],
sol=ToString[y,TraditionalForm]
];

partb={StringReplace[text, {"@a"->aa,"@b"->bb,"@c"->cc,"#c"->c,"#d"->d,"#e"->e}],vars,sol} ;


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

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


solution2=data<>ToString[Hold[Module[{aa,bb,cc,dd,ee,a, c,d,e,ff,f, gg, hh, ii, jj,i0,j0,i3,i1,i2,j1,j2,j3, text,list,sol,soly,solx, body={},vars=ertyuiop,options=ERTYUIOP, varsa, varsb, varsc,varsd,varse,index,missing,m,z},




varsa=vars[[1]];
varsb=vars[[2]];


body={
{options[[1]]<>":" ,options[[2]]<>":"},
({{aa,bb,c,d,e,a}=varsa;
sol=a;(*ToString@(SetPrecision[ToExpression[c]/(1+(ToExpression[d]/100)),7]);*)" \n"<>
ToString[tv[{"Method1",
c<>" = P + P("<>d<>"%)"<>"\n"<>
c<>" = "<>ToString[SetPrecision[1+(ToExpression[d]/100),3],TraditionalForm]<>"P\n"<>
"P = "<>ToString[ToString[c,TraditionalForm]/ToString[SetPrecision[1+(ToExpression[d]/100),3],TraditionalForm],TraditionalForm]<>"\n"<>
"P = $"<>sol,

"Method2",
c<>" = P(100% + "<>d<>"%)"<>"\n"<>
c<>" = "<>ToString[SetPrecision[1+(ToExpression[d]/100),3],TraditionalForm]<>"P\n"<>
"P = "<>ToString[ToString[c,TraditionalForm]/ToString[SetPrecision[1+(ToExpression[d]/100),3],TraditionalForm],TraditionalForm]<>"\n"<>
"P = $"<>sol,

"Method3",
"Triangle Method\n"<>
ToString[tri1["P", "(100% + "<>d<>"%)", c],TraditionalForm]<>
"\n                             ⇓"<>
"\n                         P = "<>ToString[ToString[c,TraditionalForm]/ToString[SetPrecision[1+(ToExpression[d]/100),3],TraditionalForm],TraditionalForm]<>
"\n                      P = $"<>sol
}],TraditionalForm],

(*b*) (*ANNA TO DO: make this example WORKS !!!!!!!*)
{aa,bb,c,d,e}=varsb;
soly=ToString[IntegerPart[( SetPrecision[ToExpression[c]/(1+(ToExpression[d]/100)),7]+ToExpression[e])/2],TraditionalForm ];solx=ToString[IntegerPart[( SetPrecision[ToExpression[c]/(1+(ToExpression[d]/100)),7]-ToExpression[e])/2],TraditionalForm ];" \n"(*<>sol<>"\n"<>*)<>
ToString[tv[{
"Method1:",
ToString[makeTextTable[{{"","Invested"},{aa,"x"},{bb,"y"},{"Total",sol}}],TraditionalForm]<>
"\n"<>
ToString[({{\[Piecewise], ({{" x + y = "<>sol, "---- 1 "}, {" x = y - "<>e, "---- 2"}})}}),TraditionalForm]<>"\n"<>
ToString[tv[{
"1","Method of Substitution\n"<>
"\nSubstitue 2 into 1"<>
"\n(y - "<>e<>") + y = "<>sol<>
"\ny - "<>e<>"+ y = "<>sol<>
"\n2y = "<>sol<>"+"<>e<>
"\ny = "<>ToString[ToString[sol<>" + "<>e,TraditionalForm]/2,TraditionalForm]<>
"\ny = $"<>soly<>
"\nx = "<>soly<>" - "<>e<>
"\nx = $"<>solx,

"2"," Method of Elimination:\n"<>
ToString[({{\[Piecewise], ({{" x + y = "<>sol, "---- 1 "}, {" x - y = - "<>e, "---- 2"}})}}),TraditionalForm]<>
"\nEliminate y by"<>
"\nAdding 1 and 2:"<>
"\nx + y + x - y = "<>sol<>" - "<>e<>
"\n2x = "<>sol<>" - "<>e<>
"\nx = "<>ToString[(ToString[sol<>" - "<>e,TraditionalForm])/2,TraditionalForm]<>
"\nx = $"<>solx<>
"\ny = "<>solx<>" + "<>e<>
"\ny = $"<>soly<>
"\nYou can also eliminate x by "<>
"\nSubtracting equations 1 and 2",
"3"," Alternative method of elimination\n"<>
"\nIsolate x\n"<>
ToString[({{\[Piecewise], ({{" x = -y + "<>sol, "---- 1 "}, {" x = y - "<>e, "---- 2"}})}}),TraditionalForm]<>
"\n-y + "<>sol<>" = y - "<>e<>
"\n-2y = -"<>sol<>" - "<>e<>
"\ny = "<>ToString[ToString[sol<>" + "<>e,TraditionalForm]/2,TraditionalForm]<>
"\ny = $"<>soly<>
"\nx = "<>soly<>" - "<>e<>
"\nx = $"<>solx
}],TraditionalForm]
,
"Method 2",
ToString[makeTextTable[{{"","Invested"},{bb,"x"},{aa,"x - "<>e},{"Total",sol}}],TraditionalForm]<>
"\nx + x - "<>e<>" = "<>sol<>
"\n2x = "<>sol<>" + "<>e<>
"\nx = "<>ToString[ToString[sol<>" + "<>e,TraditionalForm]/2,TraditionalForm]<>
"\nx = $"<>soly<>
"\n"<>aa<>" invested: $"<>soly<>"-$"<>e<>" = $"<>solx<>
"\n"<>bb<>" invested $"<>soly
}],TraditionalForm]
<>
"\n"(*<>"Test:"<>sol<>"\n"<>soly<>"\n"<>solx<>"\n"*)
(*ToString[SetPrecision[( SetPrecision[ToExpression[c]/(1+(ToExpression[d]/100)),7]+ToExpression[e])/2,10],TraditionalForm]<>"\n"<>
ToString[SetPrecision[(SetPrecision[ToExpression[c]/(1+(ToExpression[d]/100)),7] -ToExpression[e])/2 ,10],TraditionalForm ]<>"\n"<>
ToString[( SetPrecision[ToExpression[c]/(1+(ToExpression[d]/100)),7]     + ToExpression[e])/2,TraditionalForm]<>"\n"<>ToString[(SetPrecision[ToExpression[c]/(1+(ToExpression[d]/100)),7] - ToExpression[e])/2  ,TraditionalForm]*)


})
};

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={
{options[[1]]<>":\nLet F be the final amount",
"Let P be the original/initial amount",
"%↑ means percent increase",
(*"%↓ means percent decrease\n",*)
"Solve by",
ToString[tv[{"Method 1","F = P + P(%↑)    Percent increase\n","Method2","F = P(100% + %↑)    Percent increase","Method3",
"Triangle Method\n"<>
ToString[tri1["P", "(100% + %↑)", "F"],TraditionalForm]}],TraditionalForm], (*5*)
(*"\nMethod1",
"F = P + P(%↑)    Percent increase\n"(*F = P - P(%↓)    Percent decrease"*),
"\nMethod2","F = P(100% + %↑)    Percent increase"(*\nF = P(100% - %↓)    Percent decrease"*),
"\nMethod3",
"Triangle Method\n",
ToString[tri1["P", "(100% + %↑)", "F"],TraditionalForm],
"⇓",
"P = \!\(\*FractionBox[\(F\), \((100 %\\  + \\ \(\(%\)\(↑\)\))\)]\) ", *)

options[[2]]<>":\n"<>
ToString[tv[{"Method1",
"Set up system of equations \nSolved by\n"<>ToString[tv[{"1","Method of Subsitution","2","Method of Elimination","3","Alternative method of Elimination"}],TraditionalForm],
"Method 2","Set up one variable algebraic equation \nSolve by: \nExpand and collect like terms. \nVariable on one side = Number on the other side"}],TraditionalForm]
(*"Method1",
"Set up system of equations \nSolved by\n1) Method of Substistution \n2) Method of Elimination or \n3) Alternative Method of Elimination.",
"\nMethod2",
"Set up one variable algebraic eqaution \nSolve by: \nExpand and collect like terms. \n Variable on one side = Number on the other side"*)
},
{Null ,Null,Null,Null,Null,Null}
};

Panel[Grid[Transpose[body]]]

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

(* TODO: add more variations *)
data="\n"<>"textfghjkl:="<>ToString[{
{"Column[{makeTextTable[{{\"Year \",\"2001\",\"2002\",\"2003\",\"2004\"},{\"Number of students in Managemet\",\"\",#a,#b,\"\"}}]"<>","<>
"ToString[\"fghjkl. The chart above represents the number of students at Ryerson University in Management.\" ]"<>"}]"},


(* a *)
{"Column[{ToString[\"FGHJKLabc)Find the percentage \"<>If[ToExpression[#b]>ToExpression[#a],\"increase\",\"decrease\"]<>\" from 2002 to 2003, round to two decimal places. \",TraditionalForm]}]"},

(*b *)
{"ToString[\"FGHJKLabc)If the number of students increased by #c% from 2003 to 2004, find the number of people in Management in 2004?\",TraditionalForm]"},

(*c *)
{"ToString[\"FGHJKLabc)If the number of students in 2002 is #d% of the number of students in 2001, find the number of students in 2001. Round your answer to nearest student.\",TraditionalForm]"}

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

variation3=data<>ToString[Hold[Module[{p,a,b,c,d,e,f,g,h,i,j,i0,j0,i1,i2,i3,j1,j2,j3,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,jj0,jj1,jj2,jj3, vars,text,list,sol, parta, partb, partc, partd,parte,question,x,missing,tmp,m,z},


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

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

(*{a,b}=ToString/@(RandomInteger[{70,90},2]*100);*)

e={1,1};
While[e[[1]]==e[[2]],e=ToString/@(RandomInteger[{70,90},2]*100)];
{a,b}=e;

(* ANNA add the correct formulas *)
(*{c,d,e}=ToString/@{100,100,100};*)
(*e=ToString@100;*)

c=ToString[RandomInteger[{5,40}]];

d=ToString[RandomInteger[{105,140}]];
question=StringReplace[question, {"#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}];

vars={a,b,c,d,e};
(*Anna fix sol *)
sol=ToString[SetPrecision[((ToExpression[b]-ToExpression[a])/ToExpression[a])*100,7],TraditionalForm];

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


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


vars={aa,bb,c,d,e};
(*Anna fix sol *)
sol=ToString[IntegerPart[ (1+ ToExpression[c]/100)*ToExpression[b]],TraditionalForm];

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


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


vars={aa,bb,c,d,e};
(*Anna fix sol *)
sol=ToString[SetPrecision[ (ToExpression[a]/(ToExpression[d]/100)),10],TraditionalForm];

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


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

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


solution3=data<>ToString[Hold[Module[{aa,bb,cc,dd,ee, c,d,e,ff,f, gg, hh, ii, jj,i0,j0,i3,i1,i2,j1,j2,j3, text,list,sol,sola,solb,solc, body={},vars=ertyuiop,options=ERTYUIOP, varsa, varsb, varsc,varsd,varse,index,missing,m,z,a,b,dec},




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


body={
{options[[1]]<>":" ,options[[2]]<>":",options[[3]]<>":"},
({{aa,bb,c,d,e}=varsa;
{a,b}=e;
sola=ToString[qTrunc6[SetPrecision[((ToExpression[b]-ToExpression[a])/ToExpression[a])*100,7]],TraditionalForm]
(*ToString[
If[Abs[((ToExpression[b]-ToExpression[a])/ToExpression[a])*100]<10,
SetPrecision[((ToExpression[b]-ToExpression[a])/ToExpression[a])*100,3],
SetPrecision[((ToExpression[b]-ToExpression[a])/ToExpression[a])*100,4]

],TraditionalForm]*);"\n"<>
If[ToExpression[b]>ToExpression[a],ToString["Percentage increase: ",TraditionalForm],ToString["Percentage  decrease: ",TraditionalForm]]<>
"\n"<>If[ToExpression[b]>ToExpression[a]," %↑ = "," %↓ = "]<>ToString[(b - a )/ a,TraditionalForm]<>" × 100% \n"<>
If[ToExpression[b]>ToExpression[a]," %↑ = "," %↓ = "]<>sola<>"%\n",

(*b*)
{aa,bb,c,d,e}=varsb;
solb=ToString[ (1+ ToExpression[c]/100)*ToExpression[b],TraditionalForm];
{a,b}=e;"\n "(*<>sol<>"\n"*)<>
ToString[tv[{
"Method 1",
"F = "<>b<>" + "<>b<>"("<>c<>"%)"<>"\n"<>
"F = "<>b<>" + "<>ToString[(ToExpression[c]/100)*ToExpression[b],TraditionalForm]<>"\n"<>
"F = "<>solb,
"Method 2",
"F = "<>b<>"(100% + "<>c<>"%)"<>"\n"<>
"F = ("<>ToString[SetPrecision[1+(ToExpression[c]/100),3],TraditionalForm]<>")"<>b<>"\n"<>
"F = "<>solb,
"Method 3",
"Triangle Method\n"<>
ToString[tri1[b, "(100% + "<>c<>"%)", "F"],TraditionalForm]<>
"\n                           ⇓"<>
"\nF = "<>b<>"(100% + "<>c<>"%)"<>
"\nF = ("<>ToString[SetPrecision[1+(ToExpression[c]/100),3],TraditionalForm]<>")"<>b<>
"\nF = "<>solb

}],TraditionalForm],

(*c*)
{aa,bb,c,d,e}=varsc;
{a,b}=e;
dec=ToString[SetPrecision[ToExpression[d]/100,3],TraditionalForm];
solc=ToString[qTrunc7[SetPrecision[ (ToExpression[a]/(ToExpression[d]/100)),10]],TraditionalForm];

(*solc=ToString@(qTrunc8[SetPrecision[ (ToExpression[a]/(ToExpression[d]/100)),20],6]);*)
"\n"(*<>sol<>"\n"*)<>
ToString[tv[{
"Method1",
"(Subscript[Students, 2002]) are "<>d<>"% of (Subscript[Students, 2001])\n"<>a<>" is "<>d<>"% of x\n\n"<>ToString[(a/("x")) ,TraditionalForm]<>" = "<>ToString[(d/("100")) ,TraditionalForm]<>
"\nx = "<>ToString[((a<>"× 100")/d) ,TraditionalForm]<>
(*"\nx = "<>ToString[SetPrecision[ (ToExpression[a]/(ToExpression[d]/100)),10],TraditionalForm]<>*)
If[FractionalPart[SetPrecision[(ToExpression[a]/(ToExpression[d]/100)),10]]≠ 0,"\nx = "<>ToString[SetPrecision[ (ToExpression[a]/(ToExpression[d]/100)),10],TraditionalForm],""]<>
"\nx = "<>solc,
"Method2",
"Triangle Method\n"<>"(Subscript[Students, 2002]) are "<>d<>"% of (Subscript[Students, 2001])\n"<>a<>" is "<>d<>"% of x\n\n"<>ToString[tri1["whole", d<>"%", a],TraditionalForm]<>"\n⇓"<>
"\nwhole = "<>ToString[a/ToString[SetPrecision[ToExpression[d]/100,3],TraditionalForm],TraditionalForm]<>
If[FractionalPart[SetPrecision[(ToExpression[a]/(ToExpression[d]/100)),10]]≠ 0,"\nwhole = "<>ToString[SetPrecision[ (ToExpression[a]/(ToExpression[d]/100)),10],TraditionalForm],""]<>
"\nwhole = "<>solc

}],TraditionalForm]
})
};

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={
{options[[1]]<>":\n%↑ or %↓ = \!\(\*FractionBox[\(\(final\)\(\\ \)\(-\)\(\\ \)\(original\)\(\\ \)\), \(original\)]\) × 100%",

options[[2]]<>":\nLet F be the final amount",
"Let P be the original/initial amount",
"%↑ means percent increase",
(*"%↓ means percent decrease\n",*)
"Solve by",
ToString[tv[{
"Method1",
"F = P + P(%↑)    Percent increase"(*\nF = P - P(%↓)    Percent decrease"*),
"Method2",
"F = P(100% + %↑)    Percent increase"(*\nF = P(100% - %↓)    Percent decrease"*),
"Method3",
"Triangle Method\n" <>
ToString[tri1["P", "(100% + %↑)", "F"],TraditionalForm]
}],TraditionalForm]
, 

options[[3]]<>":\n"<>
ToString[tv[{
"Method1",
"Use definition of percents:\n (part/whole) =\!\(\*FractionBox[\(\(%\)\(\\ \)\), \(100\)]\) \n then use cross multiplication:\n whole = \!\(\*FractionBox[\(part\\ ×\\ 100\), \(%\)]\)",
"Method2",
"Triangle Method\n"<>
ToString[tri1["whole", "% ↔ decimal", "part"],TraditionalForm]
}],TraditionalForm]},

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

Panel[Grid[Transpose[body]]]

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

CONFIGURATION AREA

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";

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

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

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

};

CDF Area

CDFDeploy[ToFileName[{$UserDocumentsDirectory},"TRSM_PERCENT_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]}]]