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

data="\n"<>"textfghjkl:="<>ToString[{
{"Column[{ToString[\"fghjkl. Answer the following:\",TraditionalForm]"<>","<>"ToString[\" \"]"<>"}]","Column[{ToString[\"fghjkl. Answer each question:\",TraditionalForm]"<>","<>"ToString[\" \"]"<>"}]"},


(*a*)
{"Column[{ToString[\"FGHJKLabc)Solve for @a:\"]"<>","<>"ToString[\"#b@a-#c=#d@a+#e\",TraditionalForm]}]",
"Column[{ToString[\"FGHJKLabc)Find the value for @a:\"]"<>","<>"ToString[\"#b@a-#c=#d@a+#e\",TraditionalForm]}]"},

(*b*)
{"Column[{ToString[\"FGHJKLabc)Solve for @a:\"]"<>","<>"ToString[\" #b(@a-#c)-#d(@a+#g)=#e \",TraditionalForm]}]",
"Column[{ToString[\"FGHJKLabc)Find the value for @a:\"]"<>","<>"ToString[\"  #b(@a-#c)-#d(@a+#g)=#e  \",TraditionalForm]}]"},

(*c*)
{"Column[{ToString[\"FGHJKLabc)Solve for @g: \",TraditionalForm]"<>","<>"If[ToExpression[\"#d\"]>=0,
ToString[ToString[(\"#a @g\")/(\"#b \"),TraditionalForm]<>\" = \"<>ToString[(\"#c @g + #d\")/\"#e\",TraditionalForm],TraditionalForm],
ToString[ToString[(\"#a @g\")/(\"#b \"),TraditionalForm]<>\" = \"<>ToString[(ToString[\"#c @g - \"<>ToString[Abs[ToExpression[#d]],TraditionalForm],TraditionalForm])/\"#e\",TraditionalForm],TraditionalForm]
]"<>"}]"}  ,

(*d*)
{"Column[{ToString[\"FGHJKLabc)Solve for @g and @h\",TraditionalForm]"<>","<>
"Column[{
If[ToExpression[\"#b\"]>=0,
	If[ToExpression[\"#b\"]==1,
		ToString[\"#a @g + @h = #c\",TraditionalForm],
		If[ToExpression[\"#a\"]==1,
			ToString[\"@g + #b @h = #c\",TraditionalForm],
			ToString[\"#a @g + #b @h = #c\",TraditionalForm]
		]
	],
	If[ToExpression[\"#a\"]==1,
		ToString[\"@g #b @h = #c\",TraditionalForm],
		ToString[\"#a @g #b @h = #c\",TraditionalForm]
	]
]
,
If[ToExpression[\"#e\"]>=0,
	If[ToExpression[\"#e\"]==1,
		ToString[\"#d @g + @h = #f\",TraditionalForm],
		If[ToExpression[\"#d\"]==1,
			ToString[\"@g + #e @h = #f\",TraditionalForm],
			ToString[\"#d @g + #e @h = #f\",TraditionalForm]
		]
	],
	If[ToExpression[\"#d\"]==1,
		ToString[\"@g #e @h = #f\",TraditionalForm],
		ToString[\"#d @g #e @h = #f\",TraditionalForm]
	]
]
}]"<>"}]"},

(*e*)
{"Column[{ToString[\"FGHJKLabc)Solve for @g and @h\",TraditionalForm]"<>","<>
"Column[{
If[ToExpression[\"#b\"]>=0,
ToString[\"#a @g + #b @h = #c\",TraditionalForm],
ToString[\"#a @g #b @h = #c\",TraditionalForm]
]
,
If[ToExpression[\"#e\"]>=0,
ToString[\"#d @g + #e @h = #f\",TraditionalForm],
ToString[\"#d @g #e @h = #f\",TraditionalForm]
]
}]"<>"}]"},

(*f*)
{"Column[{ToString[\"FGHJKLabc)Solve for @g and @h\",TraditionalForm]"<>","<>
"Column[{
If[ToExpression[\"#c\"]>=0,
ToString[\"@g = #b @h + #c\",TraditionalForm],
ToString[\"@g = #b @h #c\",TraditionalForm]
]
,
If[ToExpression[\"#f\"]>=0,
ToString[\"@g = #e @h + #f\",TraditionalForm],
ToString[\"@g = #e @h #f\",TraditionalForm]
]
}]"<>"}]"}
},InputForm]<>";\n ";

variation1=data<>ToString[Hold[Module[{p,x,a,b,c,d,e,f,g,h,i,j,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,pp, vars,text,list,sol,aabbee,k, parta, partb, partc, partd,parte,partf,question,list12,teste},


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

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

{aa}=qRandList[{nLetters[{"a","y"},1]/.{"l"->"L","o"->"z"},nLetters[{"a","y"},1]/.{"l"->"L","o"->"z"}}]; 
(* bb*m +cc*(m-dd)=ee-gg*m *)
(*{bb,cc,dd,ee}=nIntegers[not0/@Range[2,10],4];*)
dd=ToString@RandomInteger[{2,12}];
bb=ToString@(RandomInteger[{2,15}]+ToExpression[dd]);
pp=ToString@RandomInteger[{2,15}];
cc=ToString@RandomInteger[{4,12}];
(*ee=ToString@(Solve[ToExpression[pp]*(ToExpression[bb]-ToExpression[dd]== x + ToExpression[cc]),x,Integers][[1]][[1]]);*)

ee=ToString@(IntegerPart[(ToExpression[pp]*(ToExpression[bb]-ToExpression[dd]))- ToExpression[cc]]);
(* use String@ to conver to String for 1 number, String/@{...} to covert a list *)
gg=ToString@(Abs[-ToExpression[bb]+ToExpression[cc]]+RandomInteger[{1,3}]);
vars={aa,bb,cc,dd,ee,gg,pp};
sol=pp;



parta={StringReplace[text, {"#c"->cc, "#d"->dd, "#a"->aa, "@a"->aa,"#b"->bb, "#c"->cc, "#g"->gg, "#e"->ee}],vars,sol(*If[Length[sol]≠0,ToString[x/.sol[[1]],InputForm], "No Solution"]*)} ;




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

{aa}=qRandList[{nLetters[{"a","y"},1]/.{"l"->"L","o"->"z"},nLetters[{"a","y"},1]/.{"l"->"L","o"->"z"}}]; 
(* bb*m +cc*(m-dd)=ee-gg*m *)
dd=ToString@RandomInteger[{2,12}];
bb=ToString@(ToExpression[dd]+RandomInteger[{3,7}]);
cc=ToString@RandomInteger[{2,12}];
gg=ToString@RandomInteger[{2,9}];
x=ToString@RandomInteger[{-10,10}];
ee=ToString@(ToExpression[x]*(ToExpression[bb]-ToExpression[dd]) - ToExpression[bb]*ToExpression[cc]-ToExpression[dd]*ToExpression[gg]);
(*{bb,cc,dd,ee}=nIntegers[not0/@Range[2,10],4];

(* use String@ to conver to String for 1 number, String/@{...} to covert a list *)
gg=ToString@(Abs[-ToExpression[bb]+ToExpression[cc]]+RandomInteger[{1,3}]);*)
vars={aa,bb,cc,dd,ee,gg,x};
sol=x;



partb={StringReplace[text, {"#c"->cc, "#d"->dd, "#a"->aa, "@a"->aa,"#b"->bb, "#c"->cc, "#g"->gg, "#e"->ee}],vars,sol(*If[Length[sol]≠0,ToString[x/.sol[[1]],InputForm], "No Solution"]*)} ;



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

{g}=qRandList[{nLetters[{"a","y"},1]/.{"l"->"L","o"->"z"},nLetters[{"a","y"},1]/.{"l"->"L","o"->"z"}}]; 


Off[Infinity::indet];

aabbee=DeleteDuplicates[RandomPrime[15,20]];
{aa,bb,ee}=ToString/@aabbee[[1;;3]];

cc=ToString@(ToExpression[ee]*ToExpression[nIntegers[Union[Range[-4,-1],Range[1,5]],1][[1]]]);

dd="0";
While[dd === "0",
dd=ToString[(ToExpression[aa]*ToExpression[ee] -ToExpression[ bb]*ToExpression[cc])*ToExpression[nIntegers[Union[Range[-3,-1],Range[1,2]],1][[1]]],TraditionalForm]
];
gg=ToString[(ToExpression[bb]*ToExpression[dd])/(ToExpression[aa]*ToExpression[ee] - ToExpression[bb]*ToExpression[cc]),TraditionalForm];

(* OLD VARIABLES:
{bb,ee,cc}=nIntegers[Union[Range[-5,-2],Range[2,5]],3];

aa=ToString[ToExpression[bb]*ToExpression[cc]*not0[RandomInteger[{2,3}]]];

dd=ToString[(-ToExpression[cc]+(ToExpression[aa]*ToExpression[ee]/ToExpression[bb]))*not0[RandomInteger[{-3,3}]]];
gg=Which[(-ToExpression[bb]*ToExpression[dd])==0&&(ToExpression[aa]*ToExpression[ee]-ToExpression[bb]*ToExpression[cc])≠0,"Infinity",
(-ToExpression[bb]*ToExpression[dd])==0&&(ToExpression[aa]*ToExpression[ee]-ToExpression[bb]*ToExpression[cc])==00, "Indeterminate",

True,ToString[Simplify[(-ToExpression[bb]*ToExpression[dd])/(ToExpression[aa]*ToExpression[ee]-ToExpression[bb]*ToExpression[cc])],InputForm]
]; *)

vars={aa,bb,cc,dd,ee,gg,g,h};

partc={StringReplace[text, {"#c"->cc, "#d"->dd, "#a"->aa, "@g"->g,"#b"->bb,   "#e"->ee}],vars,gg} ;

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

{g,h}=qRandList[{nLetters[{"a","y"},2]/.{"l"->"L","o"->"z"},nLetters[{"a","y"},2]/.{"l"->"L","o"->"z"}(*nLetters[{"α","ω"},2]/.{"π"->"A"}*)}]; 

p={1(*aa*),1(*ee*),1(*bb*),1(*dd*)};
(*CRAMER'S RULE: determinant of matrix: aa*ee - bb*dd*) 
While[p[[1]]*p[[2]]-p[[3]]*p[[4]]==0,
list12=ToExpression/@nIntegers[Union[Range[-10,-2],Range[2,10]],3];
PrependTo[list12,1];
p=RandomSample[list12];
];
{aa,ee,bb,dd}=ToString/@p;

(*aa=ToString[not0[RandomInteger[{-10,10}]]];
bb=ToString[not0[RandomInteger[{-10,10}]]];
dd=ToString[not0[RandomInteger[{-10,10}]]];
ee=ToString[not0[RandomInteger[{-10,10}]]];*)
gg=ToString[not0[RandomInteger[{-10,10}]]];
hh=ToString[not0[RandomInteger[{-10,10}]]];
cc=ToString[ToExpression[aa]*ToExpression[gg]+ToExpression[bb]*ToExpression[hh]];
ff=ToString[ToExpression[dd]*ToExpression[gg]+ToExpression[ee]*ToExpression[hh]];

vars={aa,bb,cc,dd,ee,ff,gg,hh,g,h};

partd={StringReplace[text, {"#c"->cc, "#d"->dd, "#a"->aa, "@g"->g,"@h"->h,"#b"->bb,   "#e"->ee,"#f"->ff,"#h"->hh}],vars,ToString[{ToExpression[gg],ToExpression[hh]},InputForm]} ;


(*e*)
text=qRandList[textfghjkl[[6]]];

{g,h}=qRandList[{nLetters[{"a","y"},2]/.{"l"->"L","o"->"z"},nLetters[{"a","y"},2]/.{"l"->"L","o"->"z"}(*nLetters[{"α","ω"},2]/.{"π"->"A"}*)}]; 
teste=RandomInteger[{1,2}];
p={1(*aa*),1(*bb*),1(*dd*),1(*ee*)};
(*CRAMER'S RULE: determinant of matrix: aa*ee - bb*dd*) 
While[p[[1]]*p[[4]]-p[[2]]*p[[3]]==0,

list12=ToExpression/@nIntegers[Union[(*Range[-10,-2],*)Range[2,10]],3];
k=RandomChoice[{1,2}];(*k is to check if we have same variables or opossite 1 means are oposite (we add in solution), 2 means are similar( we  substract in solution)*)
If[k==1,
AppendTo[list12,-(list12[[2]])],
AppendTo[list12,list12[[2]]]
];(*AppendTo[list12,-(list12[[2]])];*)
p=list12
(*p={not0[RandomInteger[{-10,10}]],not0[RandomInteger[{-10,10}]],not0[RandomInteger[{-10,10}]],not0[RandomInteger[{-10,10}]]}*)
];
If[teste==1,(*to check close to which parameter we have similar variables*)
{ee,dd,bb,aa}=ToString/@p;
,
{aa,bb,dd,ee}=ToString/@p;
];
(*aa=ToString[not0[RandomInteger[{-10,10}]]];
bb=ToString[not0[RandomInteger[{-10,10}]]];
dd=ToString[not0[RandomInteger[{-10,10}]]];
ee=ToString[not0[RandomInteger[{-10,10}]]];*)
gg=ToString[not0[RandomInteger[{-10,10}]]];
hh=ToString[not0[RandomInteger[{-10,10}]]];
cc=ToString[ToExpression[aa]*ToExpression[gg]+ToExpression[bb]*ToExpression[hh]];
ff=ToString[ToExpression[dd]*ToExpression[gg]+ToExpression[ee]*ToExpression[hh]];

vars={aa,bb,cc,dd,ee,ff,gg,hh,g,h,teste,ToString@k};

parte={StringReplace[text, {"#c"->cc, "#d"->dd, "#a"->aa, "@g"->g,"@h"->h,"#b"->bb,   "#e"->ee,"#f"->ff,"#h"->hh}],vars,ToString[{ToExpression[gg],ToExpression[hh]},InputForm]} ;


(*f*)
text=qRandList[textfghjkl[[7]]];

{g,h}=qRandList[{nLetters[{"a","y"},2]/.{"l"->"L","o"->"z"},nLetters[{"a","y"},2]/.{"l"->"L","o"->"z"}(*nLetters[{"α","ω"},2]/.{"π"->"A"}*)}]; 

(*p={1(*ee*),1(*bb*)};
(*CRAMER'S RULE: determinant of matrix: ee - dd*) 
While[-p[[1]]+p[[2]]==0,
p=ToExpression/@nIntegers[Union[Range[-10,-2],Range[2,10]],2]
];
{ee,bb}=ToString/@p;*)
ee=ToString@RandomInteger[{2,15}];
bb=ToString@(RandomInteger[{2,5}]+ToExpression[ee]);
aa=ToString@1;
dd=ToString@1;
(*aa=ToString[not0[RandomInteger[{-10,10}]]];
bb=ToString[not0[RandomInteger[{-10,10}]]];
dd=ToString[not0[RandomInteger[{-10,10}]]];
ee=ToString[not0[RandomInteger[{-10,10}]]];*)
gg=ToString[not0[RandomInteger[{-10,10}]]];
hh=ToString[not0[RandomInteger[{-10,10}]]];
cc=ToString[ToExpression[aa]*ToExpression[gg]-ToExpression[bb]*ToExpression[hh]];
ff=ToString[ToExpression[dd]*ToExpression[gg]-ToExpression[ee]*ToExpression[hh]];

vars={aa,bb,cc,dd,ee,ff,gg,hh,g,h};

partf={StringReplace[text, {"#c"->cc, "#d"->dd, "#a"->aa, "@g"->g,"@h"->h,"#b"->bb,   "#e"->ee,"#f"->ff,"#h"->hh}],vars,ToString[{ToExpression[gg],ToExpression[hh]},InputForm]} ;

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

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


solution1=data<>ToString[Hold[Module[{x, a,b,c,d,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj, text,list,sol, body={},vars=ertyuiop,options=ERTYUIOP, varsa, varsb, varsc,varsd,varse,varsf,g,h,pp,teste,bb1,list123,pos1,t11,t12,t21,t22,s1,s2,sum1,sum2,k},





varsa=vars[[1]];
varsb=vars[[2]];
varsc=vars[[3]];
varsd=vars[[4]];
varse=vars[[5]];
varsf=vars[[6]];

{aa,bb,cc,dd,ee,gg,pp}=varsa;
sol=Solve[ToExpression[bb]*x-ToExpression[cc]*(x-ToExpression[dd])==ToExpression[ee]-ToExpression[gg]*x,x];



body={
{ToString[Column[{

options[[1]]<>": \n"<>bb<>aa<>" - "<>cc<>" = "<>dd<>aa<>" + "<>ee<>"\n"<>
bb<>aa<>" - "<>dd<>aa<>" = "<>ee<>"+ "<>cc<>"\n"<>
ToString[ToExpression[bb]-ToExpression[dd],TraditionalForm]<>aa<>" = "<>ToString[ToExpression[ee]+ToExpression[cc],TraditionalForm]<>"\n"<>aa<>" = "<>pp<>"\n"
,

(*b*)
{aa,bb,cc,dd,ee,gg,x}=varsb; 
options[[2]]<>": \n"<>bb<>"("<>aa<>" - "<>cc<>") - "<>dd<>"("<>aa<>" + "<>gg<>") = "<>ee<>"\n"<>
bb<>aa<>" - "<>ToString[ToExpression[bb]*ToExpression[cc]]<>" - "<>dd<>aa<>" - "<>ToString[ToExpression[dd]*ToExpression[gg],TraditionalForm]<>" = "<>ee<>"\n"<>
ToString[ToExpression[bb] -ToExpression[ dd],TraditionalForm]<>aa<>" - "<>ToString[ToExpression[bb]*ToExpression[cc]+ToExpression[dd]*ToExpression[gg]]<>" = "<>ee<>"\n"<>
ToString[ToExpression[bb] -ToExpression[ dd],TraditionalForm]<>aa<>" = "<>ToString[ToExpression[ee]+ToExpression[bb]*ToExpression[cc]+ToExpression[dd]*ToExpression[gg]]<>"\n"<>aa<>" = "<>x<>"\n"
,  

(*c*)
{aa,bb,cc,dd,ee,gg,g,h}=varsc; 
options[[3]]<>": \n"<>
ToString[(aa<>g)/bb,TraditionalForm]<>" = "<>ToString[(ToString[cc*g,TraditionalForm]<>If[ToExpression[dd]>0," + "<>dd," - "<>ToString[Abs[ToExpression[dd]],TraditionalForm]])/(ToString[ee,TraditionalForm]),TraditionalForm]<>"\n"<>
ToString[ee,TraditionalForm]<>"("<>aa<>g<>") = "<>bb<>"("<>ToString[cc*g,TraditionalForm]<>If[ToExpression[dd]>0," + "<>ToString[dd,TraditionalForm]," - "<>ToString[Abs[ToExpression[dd]],TraditionalForm]]<>")\n"<>
(*3*)
ToString[ToExpression[ee]*ToExpression[aa],TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>ToString[ToExpression[cc]*ToExpression[bb],TraditionalForm]<>ToString[g,TraditionalForm]<>If[(ToExpression[dd]*ToExpression[bb]>0)," + "<>ToString[Abs[ToExpression[bb]*ToExpression[dd]],TraditionalForm]," - "<>ToString[Abs[ToExpression[bb]*ToExpression[dd]],TraditionalForm]]<>"\n"<>
(*4*)
ToString[ToExpression[ee]*ToExpression[aa]-ToExpression[cc]*ToExpression[bb],TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>If[(ToExpression[dd]*ToExpression[bb]>0),ToString[Abs[ToExpression[bb]*ToExpression[dd]],TraditionalForm],ToString[ToExpression[bb]*ToExpression[dd],TraditionalForm]]<>"\n"<>
ToString[g,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>"\n"



}],TraditionalForm],

(*d*)
{aa,bb,cc,dd,ee,ff,gg,hh,g,h}=varsd; 
list123={aa,bb,dd,ee};
pos1=Position[list123,"1"];
Which[pos1=={{1}},t11=aa;t12=bb;s1=g;t21=dd;t22=ee;s2=h;sum1=cc;sum2=ff,
pos1=={{2}},t11=bb;t12=aa;s1=h;t21=ee;t22=dd;s2=g;sum1=cc;sum2=ff,
pos1=={{3}},t11=dd;t12=ee;s1=g;t21=aa;t22=bb;s2=h;sum1=ff;sum2=cc,
pos1=={{4}},t11=ee;t12=dd;s1=h;t21=bb;t22=aa;s2=g;sum1=ff;sum2=cc];
options[[4]]<>": \n"<>ToString[tv[{
"Method 1",
"Method of Substitustion\n"<>
ToString[({{\[Piecewise], ({{s1<>" = "<>sum1<>If[ToExpression[t12]>0," - "," + "]<>ToString[Abs[ToExpression[t12]],TraditionalForm]<>s2, "·····1"}, {t21<>s1<>If[ToExpression[t22]>0," + "," "]<>t22<>s2<>" = "<>sum2, "·····2"}})}}),TraditionalForm]<>"\nSubstiutute 1 into \!2\n"<>
t21<>"("<>sum1<>If[ToExpression[t12]>0," - "," + "]<>ToString[Abs[ToExpression[t12]],TraditionalForm]<>s2<>")"<>If[ToExpression[t22]>0," + "," "]<>t22<>s2<>" = "<>sum2<>"\n"<>
ToString[ToExpression[t21]*ToExpression[sum1]]<>If[(-(ToExpression[t12]))*ToExpression[t21]>0,"+ "," "]<>ToString[(-(ToExpression[t12]))*ToExpression[t21],TraditionalForm]<>s2<>If[ToExpression[t22]>0," + "," "]<>t22<>s2<>" = "<>sum2<>"\n"<>
ToString[(-(ToExpression[t12]))*ToExpression[t21]+ToExpression[t22],TraditionalForm]<>s2<>" = "<>sum2<>" - ("<>ToString[ToExpression[t21]*ToExpression[sum1]]<>")\n"<>
ToString[(-(ToExpression[t12]))*ToExpression[t21]+ToExpression[t22],TraditionalForm]<>s2<>" = "<>ToString[ToExpression[sum2] - ToExpression[t21]*ToExpression[sum1]]<>"\n"<>

s2<>" = "<>ToString[(ToExpression[sum2] - ToExpression[t21]*ToExpression[sum1])/((-(ToExpression[t12]))*ToExpression[t21]+ToExpression[t22])]<>"\n\n"<>
s1<>" = "<>sum1<>If[ToExpression[t12]>0," - "," + "]<>ToString[Abs[ToExpression[t12]],TraditionalForm]<>"("<>ToString[(ToExpression[sum2] - ToExpression[t21]*ToExpression[sum1])/((-(ToExpression[t12]))*ToExpression[t21]+ToExpression[t22])]<>")"<>"\n"<>
s1<>" = "
ToString[ToExpression[sum1]-ToExpression[t12]*
((ToExpression[sum2] - ToExpression[t21]*ToExpression[sum1])/((-(ToExpression[t12]))*ToExpression[t21]+ToExpression[t22])),TraditionalForm]<>"\n\n"<>
ToString[g,TraditionalForm]<>", "<>ToString[h,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>" "<>ToString[hh,TraditionalForm]
,
"Method 2",
"Method of Elimination\n"<>
ToString[({{\[Piecewise], ({{aa<>g<>If[ToExpression[bb]>0," + ",""]<>bb<>h<>" = "<>cc, "·····1 \[Cross] "<>dd}, {dd<>ToString[g,TraditionalForm]<>If[ToExpression[ee]>0," + ",""]<>ee<>h<>" = "<>ff, "·····2 \[Cross] "<>aa}})}}),TraditionalForm]<>"\n"<>
ToString[({{\[Piecewise], ({{ToString[ToExpression[dd]*ToExpression[aa],TraditionalForm]<>g<>If[(ToExpression[dd]*ToExpression[bb])>0," + ",""]<>ToString[ToExpression[dd]*ToExpression[bb],TraditionalForm]<>h<>" = "<>ToString[ToExpression[dd]*ToExpression[cc],TraditionalForm], "·····1"}, {ToString[ToExpression[aa]*ToExpression[dd],TraditionalForm]<>g<>If[(ToExpression[aa]*ToExpression[ee])>0," + ",""]<>ToString[ToExpression[aa]*ToExpression[ee],TraditionalForm]<>h<>" = "<>ToString[ToExpression[aa]*ToExpression[ff],TraditionalForm], "·····2"}})}}),TraditionalForm]<>"\n"


<>"Substract: 1 - 2 : \n"<>
ToString[ToExpression[dd]*ToExpression[bb]-ToExpression[aa]*ToExpression[ee],TraditionalForm]<>ToString[h,TraditionalForm]<>" = "<>ToString[ToExpression[dd]*ToExpression[cc] -ToExpression[aa]*ToExpression[ff] ,TraditionalForm]<>"\n"<>
ToString[h,TraditionalForm]<>" = "<>ToString[hh,TraditionalForm]<>"\n\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>If[ToExpression[bb]>0," + ",""]<>ToString[bb,TraditionalForm]<>"("<>ToString[hh(*gg*),TraditionalForm]<>") = "<>ToString[cc,TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>ToString[cc,TraditionalForm]<>If[ToExpression[hh]*ToExpression[bb]>0," - "," + "]<>ToString[Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>If[ToExpression[hh]*ToExpression[bb]>0,ToString[ToExpression[cc]-Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm],ToString[ToExpression[cc]+Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]]<>"\n"<>
ToString[g,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>"\n\n"<>
ToString[g,TraditionalForm]<>", "<>ToString[h,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>" "<>ToString[hh,TraditionalForm],
"Method 3",
"Alternative Method of Elimination\n"<>
ToString[({{\[Piecewise], ({{aa<>g<>If[ToExpression[bb]>0," + ",""]<>bb<>h<>" = "<>cc, "·····1 \[Cross] "<>dd}, {dd<>ToString[g,TraditionalForm]<>If[ToExpression[ee]>0," + ",""]<>ee<>h<>" = "<>ff, "·····2 \[Cross] "<>aa}})}}),TraditionalForm]<>"\n"<>
ToString[({{\[Piecewise], ({{ToString[ToExpression[dd]*ToExpression[aa],TraditionalForm]<>g<>If[(ToExpression[dd]*ToExpression[bb])>0," + ",""]<>ToString[ToExpression[dd]*ToExpression[bb],TraditionalForm]<>h<>" = "<>ToString[ToExpression[dd]*ToExpression[cc],TraditionalForm], "·····1"}, {ToString[ToExpression[aa]*ToExpression[dd],TraditionalForm]<>g<>If[(ToExpression[aa]*ToExpression[ee])>0," + ",""]<>ToString[ToExpression[aa]*ToExpression[ee],TraditionalForm]<>h<>" = "<>ToString[ToExpression[aa]*ToExpression[ff],TraditionalForm], "·····2"}})}}),TraditionalForm]<>"\n"


<>"Isolate "<>ToString[ToExpression[aa]*ToExpression[dd],TraditionalForm]<>" "<>g<>" \n"<>
ToString[({{\[Piecewise], ({{ToString[ToExpression[dd]*ToExpression[aa],TraditionalForm]<>g<>" = "<>ToString[ToExpression[dd]*ToExpression[cc],TraditionalForm]<>If[(ToExpression[dd]*ToExpression[bb])>0," - "," + "]<>ToString[Abs[ToExpression[dd]*ToExpression[bb]],TraditionalForm]<>h, "·····1"}, {ToString[ToExpression[aa]*ToExpression[dd],TraditionalForm]<>g<>" = "<>ToString[ToExpression[aa]*ToExpression[ff],TraditionalForm]<>If[(ToExpression[aa]*ToExpression[ee])>0," - "," + "]<>ToString[Abs[ToExpression[aa]*ToExpression[ee]],TraditionalForm]<>h, "·····2"}})}}),TraditionalForm]<>"\n"
<>ToString[ToExpression[dd]*ToExpression[cc],TraditionalForm]<>If[(ToExpression[dd]*ToExpression[bb])>0," - "," + "]<>ToString[Abs[ToExpression[dd]*ToExpression[bb]],TraditionalForm]<>h<>" = "<>ToString[ToExpression[aa]*ToExpression[ff],TraditionalForm]<>If[(ToExpression[aa]*ToExpression[ee])>0," - "," + "]<>ToString[Abs[ToExpression[aa]*ToExpression[ee]],TraditionalForm]<>h<>"\n"

<>If[(ToExpression[dd]*ToExpression[bb])>0," - ",""]<>ToString[Abs[ToExpression[dd]*ToExpression[bb]],TraditionalForm]<>h<>If[(ToExpression[aa]*ToExpression[ee])>0," + "," - "]<>ToString[Abs[ToExpression[aa]*ToExpression[ee]],TraditionalForm]<>h<>" = "<>ToString[ToExpression[aa]*ToExpression[ff],TraditionalForm]<>" - ("<>ToString[ToExpression[dd]*ToExpression[cc],TraditionalForm]<>")\n"

<>ToString[ToExpression[If[(ToExpression[dd]*ToExpression[bb])>0," - ",""]<>ToString[Abs[ToExpression[dd]*ToExpression[bb]],TraditionalForm]] + ToExpression[aa]*ToExpression[ee],TraditionalForm]<>h<>" = "<>ToString[ToExpression[aa]*ToExpression[ff]-ToExpression[dd]*ToExpression[cc],TraditionalForm]<>"\n"
<>ToString[h,TraditionalForm]<>" = "<>ToString[hh,TraditionalForm]<>"\n\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>If[ToExpression[bb]>0," + ",""]<>ToString[bb,TraditionalForm]<>"("<>ToString[hh(*gg*),TraditionalForm]<>") = "<>ToString[cc,TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>ToString[cc,TraditionalForm]<>If[ToExpression[hh]*ToExpression[bb]>0," - "," + "]<>ToString[Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>If[ToExpression[hh]*ToExpression[bb]>0,ToString[ToExpression[cc]-Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm],ToString[ToExpression[cc]+Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]]<>"\n"<>
ToString[g,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>"\n\n"<>
ToString[g,TraditionalForm]<>", "<>ToString[h,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>" "<>ToString[hh,TraditionalForm]

}],TraditionalForm]

,  


(*e*)
{aa,bb,cc,dd,ee,ff,gg,hh,g,h,teste,k}=varse; 
bb1=ToString[Abs[ToExpression[bb]]];
options[[5]]<>": \n"<>ToString[tv[{"Method 1",
"Method of Substitustion\n"<>ToString[({{\[Piecewise], ({{g<>" = "<>ToString[(1/aa),TraditionalForm]<>"("<>cc<>If[ToExpression[bb]>0," - "," + "]<>bb1<>h<>")", "····· 1"}, {dd<>g<>If[ToExpression[ee]>0," + ",""]<>ee<>h<>" = "<>ff, "····· 2"}})}}),TraditionalForm]<>"\n"<>
"Substitute 1 into 2"<>"\n"<>
dd<>"["<>ToString[(1/aa),TraditionalForm]<>"("<>cc<>If[ToExpression[bb]>0," - "," + "]<>bb1<>h<>")"<>"]"<>If[ToExpression[ee]>0," + ",""]<>ee<>h<>" = "<>ff<>"  ······ × "<>aa<>"\n"<>
dd<>"("<>cc<>If[ToExpression[bb]>0," - "," + "]<>bb1<>h<>")"<>If[ToExpression[ee]*ToExpression[aa]>0," + ",""]<>ToString[ToExpression[ee]*ToExpression[aa],TraditionalForm]<>h<>" = "<>ToString[ToExpression[aa]*ToExpression[ff]]<>"\n"<>

ToString[ToExpression[dd]*ToExpression[cc],TraditionalForm]<>If[ToExpression[bb]*ToExpression[dd]>0," - "," + "]<>ToString[Abs[ToExpression[dd]*ToExpression[bb]]]<>h<>If[ToExpression[ee]*ToExpression[aa]>0," + ",""]<>ToString[ToExpression[ee]*ToExpression[aa],TraditionalForm]<>h<>" = "<>ToString[ToExpression[aa]*ToExpression[ff]]<>"\n"<>

ToString[ToExpression[dd]*(-ToExpression[bb]) + ToExpression[ee]*ToExpression[aa]]<>h<>" = "<>ToString[ToExpression[aa]*ToExpression[ff] - ToExpression[dd]*ToExpression[cc]]<>"\n"<>




ToString[h,TraditionalForm]<>" = "<>ToString[hh,TraditionalForm]<>"\n\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>If[ToExpression[bb]>0," + ",""]<>ToString[bb,TraditionalForm]<>"("<>ToString[hh(*gg*),TraditionalForm]<>") = "<>ToString[cc,TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>ToString[cc,TraditionalForm]<>If[ToExpression[hh]*ToExpression[bb]>0," - "," + "]<>ToString[Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>If[ToExpression[hh]*ToExpression[bb]>0,ToString[ToExpression[cc]-Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm],ToString[ToExpression[cc]+Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]]<>"\n"<>
ToString[g,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>"\n\n"<>
ToString[g,TraditionalForm]<>", "<>ToString[h,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>" "<>ToString[hh,TraditionalForm]
,
"Method 2",
"Method of Elimination\n"<>ToString[({{\[Piecewise], ({{aa<>g<>If[ToExpression[bb]>0," + ",""]<>bb<>h<>" = "<>cc, "····· 1"}, {dd<>g<>If[ToExpression[ee]>0," + ",""]<>ee<>h<>" = "<>ff, "····· 2"}})}}),TraditionalForm]<>"\n"<>
If[ToExpression[k]==1,"Add 1 and 2 :","Substract 1 and 2 :"]<>

"\n"<>

Which[teste==1,
(*bb<>h<>" + ("<>ee<>h<>") = "<>ToString[ToExpression[cc]+ToExpression[ff],TraditionalForm]<>"\n"<>*)
If[ToExpression[k]==1,
ToString[ToExpression[bb]+ToExpression[ee],TraditionalForm]<>h<>" = "<>ToString[ToExpression[cc]+ToExpression[ff],TraditionalForm],
ToString[ToExpression[bb]-ToExpression[ee],TraditionalForm]<>h<>" = "<>ToString[ToExpression[cc]-ToExpression[ff],TraditionalForm]
]<>"\n"<>

ToString[h,TraditionalForm]<>" = "<>ToString[hh,TraditionalForm]<>"\n\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>If[ToExpression[bb]>0," + ",""]<>ToString[bb,TraditionalForm]<>"("<>ToString[hh(*gg*),TraditionalForm]<>") = "<>ToString[cc,TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>ToString[cc,TraditionalForm]<>If[ToExpression[hh]*ToExpression[bb]>0," - "," + "]<>ToString[Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>If[ToExpression[hh]*ToExpression[bb]>0,ToString[ToExpression[cc]-Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm],ToString[ToExpression[cc]+Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]]<>"\n"<>
ToString[g,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]

,
teste==2,
(*aa<>g<>" + ("<>dd<>g<>") = "<>ToString[ToExpression[cc]+ToExpression[ff],TraditionalForm]<>"\n"<>*)
If[ToExpression[k]==1,
ToString[ToExpression[aa]+ToExpression[dd],TraditionalForm]<>g<>" = "<>ToString[ToExpression[cc]+ToExpression[ff],TraditionalForm],
ToString[ToExpression[aa]-ToExpression[dd],TraditionalForm]<>g<>" = "<>ToString[ToExpression[cc]-ToExpression[ff],TraditionalForm]
]<>"\n"<>
g<>" = "<>gg<>"\n\n"<>

aa<>"("<>gg<>")"<>If[ToExpression[bb]>0," + ",""]<>bb<>h<>" = "<>cc<>"\n"<>
bb<>h<>" = "<>ToString[cc,TraditionalForm]<>If[ToExpression[aa]*ToExpression[gg]>0," - "," + "]<>ToString[Abs[ToExpression[aa]*ToExpression[gg]],TraditionalForm]<>"\n"<>
ToString[bb,TraditionalForm]<>ToString[h,TraditionalForm]<>" = "<>If[ToExpression[aa]*ToExpression[gg]>0,ToString[ToExpression[cc]-Abs[ToExpression[aa]*ToExpression[gg]],TraditionalForm],ToString[ToExpression[cc]+Abs[ToExpression[aa]*ToExpression[gg]],TraditionalForm]]<>"\n"<>
ToString[h,TraditionalForm]<>" = "<>ToString[hh,TraditionalForm]

]<>"\n\n"<>
ToString[g,TraditionalForm]<>", "<>ToString[h,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>" "<>ToString[hh,TraditionalForm],

"Method 3",
"Alternative Method of Elimination\n"<>
(*ToString[({{\[Piecewise], ({{aa<>g<>If[ToExpression[bb]>0," + ",""]<>bb<>h<>" = "<>cc, "····· 1"}, {dd<>g<>If[ToExpression[ee]>0," + ",""]<>ee<>h<>" = "<>ff, "····· 2"}})}}),TraditionalForm]<>"\n"<>*)
If[ToExpression[k]==2,
If[teste==1,
"Isolate "<>aa<>g<>"\n"<>
ToString[({{\[Piecewise], ({{aa<>g<>" = "<>cc<>If[ToExpression[bb]>0," - "," + "]<>ToString[Abs[ToExpression[bb]],TraditionalForm]<>h, "····· 1"}, {dd<>g<>" = "<>ff<>If[ToExpression[ee]>0," - "," + "]<>ToString[Abs[ToExpression[ee]],TraditionalForm]<>h, "····· 2"}})}}),TraditionalForm]<>"\n"<>
cc<>If[ToExpression[bb]>0," - "," + "]<>ToString[Abs[ToExpression[bb]],TraditionalForm]<>h<>" = "<>ff<>If[ToExpression[ee]>0," - "," + "]<>ToString[Abs[ToExpression[ee]],TraditionalForm]<>h<>"\n"<>
ToString[ToExpression[bb]-ToExpression[ee],TraditionalForm]<>h<>" = "<>ToString[ToExpression[cc]-ToExpression[ff],TraditionalForm]<>"\n"<>
h<>" = "<>hh<>"\n\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>If[ToExpression[bb]>0," + ",""]<>ToString[bb,TraditionalForm]<>"("<>ToString[hh(*gg*),TraditionalForm]<>") = "<>ToString[cc,TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>ToString[cc,TraditionalForm]<>If[ToExpression[hh]*ToExpression[bb]>0," - "," + "]<>ToString[Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>If[ToExpression[hh]*ToExpression[bb]>0,ToString[ToExpression[cc]-Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm],ToString[ToExpression[cc]+Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]]<>"\n"<>
ToString[g,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]

,
"Isolate "<>bb<>h<>"\n"<>
ToString[({{\[Piecewise], ({{bb<>h<>" = "<>cc<>If[ToExpression[aa]>0," - "," + "]<>ToString[Abs[ToExpression[aa]],TraditionalForm]<>g, "····· 1"}, {ee<>h<>" = "<>ff<>If[ToExpression[dd]>0," - "," + "]<>ToString[Abs[ToExpression[dd]],TraditionalForm]<>g, "····· 2"}})}}),TraditionalForm]<>"\n"<>
cc<>If[ToExpression[aa]>0," - "," + "]<>ToString[Abs[ToExpression[aa]],TraditionalForm]<>g<>" = "<>ff<>If[ToExpression[dd]>0," - "," + "]<>ToString[Abs[ToExpression[dd]],TraditionalForm]<>g<>"\n"<>
ToString[ToExpression[aa]-ToExpression[dd],TraditionalForm]<>g<>" = "<>ToString[ToExpression[cc]-ToExpression[ff],TraditionalForm]<>"\n"<>
g<>" = "<>gg<>"\n\n"<>

aa<>"("<>gg<>")"<>If[ToExpression[bb]>0," + ",""]<>bb<>h<>" = "<>cc<>"\n"<>
bb<>h<>" = "<>ToString[cc,TraditionalForm]<>If[ToExpression[aa]*ToExpression[gg]>0," - "," + "]<>ToString[Abs[ToExpression[aa]*ToExpression[gg]],TraditionalForm]<>"\n"<>
ToString[bb,TraditionalForm]<>ToString[h,TraditionalForm]<>" = "<>If[ToExpression[aa]*ToExpression[gg]>0,ToString[ToExpression[cc]-Abs[ToExpression[aa]*ToExpression[gg]],TraditionalForm],ToString[ToExpression[cc]+Abs[ToExpression[aa]*ToExpression[gg]],TraditionalForm]]<>"\n"<>
ToString[h,TraditionalForm]<>" = "<>ToString[hh,TraditionalForm]

]
,
If[teste==1,
ToString[({{\[Piecewise], ({{aa<>g<>If[ToExpression[bb]>0," + ",""]<>bb<>h<>" = "<>cc, "····· 1 ×(-1)"}, {dd<>g<>If[ToExpression[ee]>0," + ",""]<>ee<>h<>" = "<>ff, "····· 2"}})}}),TraditionalForm]<>"\n"<>
ToString[({{\[Piecewise], ({{ToString[(-1)*ToExpression[aa],TraditionalForm]<>g<>If[(ToExpression[bb]*(-1))>0," + ",""]<>ToString[(-1)*ToExpression[bb],TraditionalForm]<>h<>" = "<>ToString[(-1)*ToExpression[cc],TraditionalForm], "····· 1 "}, {dd<>g<>If[ToExpression[ee]>0," + ",""]<>ee<>h<>" = "<>ff, "····· 2"}})}}),TraditionalForm]<>"\n"<>
"Isolate "<>dd<>g<>"\n"<>
ToString[({{\[Piecewise], ({{ToString[(-1)*ToExpression[aa],TraditionalForm]<>g<>" = "<>ToString[(-1)*ToExpression[cc],TraditionalForm]<>" - ("<>ToString[(-1)*ToExpression[bb],TraditionalForm]<>h<>")", "····· 1 "}, {dd<>g<>" = "<>ff<>" - ("<>ee<>h<>")", "····· 2"}})}}),TraditionalForm]<>"\n"<>
ToString[(-1)*ToExpression[cc],TraditionalForm]<>" - ("<>ToString[(-1)*ToExpression[bb],TraditionalForm]<>h<>") = "<>ff<>" - ("<>ee<>h<>")\n"<>
h<>" = "<>hh<>"\n\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>If[ToExpression[bb]>0," + ",""]<>ToString[bb,TraditionalForm]<>"("<>ToString[hh(*gg*),TraditionalForm]<>") = "<>ToString[cc,TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>ToString[cc,TraditionalForm]<>If[ToExpression[hh]*ToExpression[bb]>0," - "," + "]<>ToString[Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]<>"\n"<>
ToString[aa,TraditionalForm]<>ToString[g,TraditionalForm]<>" = "<>If[ToExpression[hh]*ToExpression[bb]>0,ToString[ToExpression[cc]-Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm],ToString[ToExpression[cc]+Abs[ToExpression[hh]*ToExpression[bb]],TraditionalForm]]<>"\n"<>
ToString[g,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]


,

ToString[({{\[Piecewise], ({{aa<>g<>If[ToExpression[bb]>0," + ",""]<>bb<>h<>" = "<>cc, "····· 1"}, {dd<>g<>If[ToExpression[ee]>0," + ",""]<>ee<>h<>" = "<>ff, "····· 2 ×(-1)"}})}}),TraditionalForm]<>"\n"<>
ToString[({{\[Piecewise], ({{aa<>g<>If[ToExpression[bb]>0," + ",""]<>bb<>h<>" = "<>cc, "····· 1"}, {ToString[(-1)*ToExpression[dd],TraditionalForm]<>g<>If[(ToExpression[ee]*(-1))>0," + ",""]<>ToString[(-1)*ToExpression[ee],TraditionalForm]<>h<>" = "<>ToString[(-1)*ToExpression[ff],TraditionalForm], "····· 2 "}})}}),TraditionalForm]<>"\n"<>
"Isolate "<>bb<>h<>"\n"<>
ToString[({{\[Piecewise], ({{bb<>h<>" = "<>cc <>" - ("<> aa<>g<>")", "····· 1"}, {ToString[(-1)*ToExpression[ee],TraditionalForm]<>h<>" = "<>ToString[(-1)*ToExpression[ff],TraditionalForm]<>" - ("<>ToString[(-1)*ToExpression[dd],TraditionalForm]<>g<>")", "····· 2 "}})}}),TraditionalForm]<>"\n"<>
cc <>" - ("<> aa<>g<>") = "<>ToString[(-1)*ToExpression[ff],TraditionalForm]<>" - ("<>ToString[(-1)*ToExpression[dd],TraditionalForm]<>g<>")\n"<>
g<>" = "<>gg<>"\n\n"<>

aa<>"("<>gg<>")"<>If[ToExpression[bb]>0," + ",""]<>bb<>h<>" = "<>cc<>"\n"<>
bb<>h<>" = "<>ToString[cc,TraditionalForm]<>If[ToExpression[aa]*ToExpression[gg]>0," - "," + "]<>ToString[Abs[ToExpression[aa]*ToExpression[gg]],TraditionalForm]<>"\n"<>
ToString[bb,TraditionalForm]<>ToString[h,TraditionalForm]<>" = "<>If[ToExpression[aa]*ToExpression[gg]>0,ToString[ToExpression[cc]-Abs[ToExpression[aa]*ToExpression[gg]],TraditionalForm],ToString[ToExpression[cc]+Abs[ToExpression[aa]*ToExpression[gg]],TraditionalForm]]<>"\n"<>
ToString[h,TraditionalForm]<>" = "<>ToString[hh,TraditionalForm]


]]<>"\n\n"<>ToString[g,TraditionalForm]<>", "<>ToString[h,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>" "<>ToString[hh,TraditionalForm]

}],TraditionalForm]
(*<>"\n"<>

ToString[g,TraditionalForm]<>", "<>ToString[h,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>" "<>ToString[hh,TraditionalForm]<>"\n"*),  


(*f*)
{aa,bb,cc,dd,ee,ff,gg,hh,g,h}=varsf; 
options[[6]]<>": \n"<>
ToString[tv[{"Method 1",
"Method of Substitustion\n"<>
ToString[({{\[Piecewise], ({{g<>" = "<>bb<>h<>If[ToExpression[cc]≥0," + ",""]<>cc, "····· 1"}, {g<>" = "<>ee<>h<>If[ToExpression[ff]≥0," + ",""]<>ff, "····· 2"}})}}),TraditionalForm]<>
"\nSubstitute 1 into 2\n"<>
bb<>h<>If[ToExpression[cc]≥0," + ",""]<>cc<>" = "<>ee<>h<>If[ToExpression[ff]≥0," + ",""]<>ff<>"\n"<>
bb<>h<>" - "<>ee<>h<>" = "<>ff <>If[ToExpression[cc]≥0," - "," + "]<>ToString[Abs[ToExpression[cc]],TraditionalForm]<>"\n"<>
ToString[ToExpression[bb]-ToExpression[ee],TraditionalForm]<>h<>" = "<>ToString[ToExpression[ff] -ToExpression[cc],TraditionalForm]<>"\n"<>
h<>" = "<>hh<>"\n\n"<>
g<>" = "<>bb<>"("<>hh<>")"<>If[ToExpression[cc]≥0," + ",""]<>cc<>"\n"<>
g<>" = "<>gg<>"\n\n"<>
ToString[g,TraditionalForm]<>", "<>ToString[h,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>" "<>ToString[hh,TraditionalForm],
"Method 2",
"Method of Elimination\n"<>
ToString[({{\[Piecewise], ({{g<>" = "<>bb<>h<>If[ToExpression[cc]≥0," + ",""]<>cc, "····· 1"}, {g<>" = "<>ee<>h<>If[ToExpression[ff]≥0," + ",""]<>ff, "····· 2"}})}}),TraditionalForm]<>"\n"<>
"Eliminate "<>g<>" by substracting 1 and 2\n"<>
"0 = "<>bb<>h<>If[ToExpression[cc]≥0," + ",""]<>cc<>" - ("<>ee<>h<>If[ToExpression[ff]≥0," + ",""]<>ff<>")\n"<>
"0 = "<>bb<>h<>" - "<>ee<>h<>If[ToExpression[cc]≥0," + ",""]<>cc <>" - (" <>ff<>")\n"<>
bb<>h<>" - "<>ee<>h<>" = "<>ff <>If[ToExpression[cc]≥0," - "," + "]<>ToString[Abs[ToExpression[cc]],TraditionalForm]<>"\n"<>
ToString[ToExpression[bb]-ToExpression[ee],TraditionalForm]<>h<>" = "<>ToString[ToExpression[ff] -ToExpression[cc],TraditionalForm]<>"\n"<>
h<>" = "<>hh<>"\n\n"<>
g<>" = "<>bb<>"("<>hh<>")"<>If[ToExpression[cc]≥0," + ",""]<>cc<>"\n"<>
g<>" = "<>gg<>"\n\n"<>
ToString[g,TraditionalForm]<>", "<>ToString[h,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>" "<>ToString[hh,TraditionalForm]
,
"Method 3",
"Alternative Method of Elimination\n"<>g<>" is isolated\n"<>
ToString[({{\[Piecewise], ({{g<>" = "<>bb<>h<>If[ToExpression[cc]≥0," + ",""]<>cc, "····· 1"}, {g<>" = "<>ee<>h<>If[ToExpression[ff]≥0," + ",""]<>ff, "····· 2"}})}}),TraditionalForm]<>"\n"<>
bb<>h<>If[ToExpression[cc]≥0," + ",""]<>cc<>" = "<>ee<>h<>If[ToExpression[ff]≥0," + ",""]<>ff<>"\n"<>
bb<>h<>" - "<>ee<>h<>" = "<>ff <>If[ToExpression[cc]≥0," - "," + "]<>ToString[Abs[ToExpression[cc]],TraditionalForm]<>"\n"<>
ToString[ToExpression[bb]-ToExpression[ee],TraditionalForm]<>h<>" = "<>ToString[ToExpression[ff] -ToExpression[cc],TraditionalForm]<>"\n"<>
h<>" = "<>hh<>"\n\n"<>
g<>" = "<>bb<>"("<>hh<>")"<>If[ToExpression[cc]≥0," + ",""]<>cc<>"\n"<>
g<>" = "<>gg<>"\n\n"<>
ToString[g,TraditionalForm]<>", "<>ToString[h,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>" "<>ToString[hh,TraditionalForm]
}],TraditionalForm](*<>"\n"<>
ToString[g,TraditionalForm]<>", "<>ToString[h,TraditionalForm]<>" = "<>ToString[gg,TraditionalForm]<>" "<>ToString[hh,TraditionalForm]<>"\n"*)

}, 
{Null ,Null, 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[{
options[[1]]<>": \n"<>"Collect like terms.\nVariables on one side = Number on the other side\n", 
options[[2]]<>": \n"<>"Expand and collect like terms.\nVariables on one side = Number on the other side\n",
options[[3]]<>": \n"<>"Use cross multiplication (a/b) = (x/c) ⟹ x = (ac/b)\n",
options[[4]]<>": \n"<>"Solve by:\n"<>ToString[tv[{"Method 1","Method of Substitustion","Method 2","Method of Elimination","Method 3","Alternative Method of Elimination"}],TraditionalForm], 
options[[5]]<>": \n"<>"Solve by:\n"<>ToString[tv[{"Method 1","Method of Substitustion","Method 2","Method of Elimination","Method 3","Alternative Method of Elimination"}],TraditionalForm],
options[[6]]<>": \n"<>"Solve by:\n"<>ToString[tv[{"Method 1","Method of Substitustion","Method 2","Method of Elimination","Method 3","Alternative Method of Elimination"}],TraditionalForm]
}],TraditionalForm]
},
{Null(* ,Null, Null,Null ,Null, Null*)}
};

Panel[Grid[Transpose[body]]]

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

data="\n"<>"textfghjkl:="<>ToString[{
{"Column[{ToString[\"fghjkl. A company payes its employees according to the formula:\",TraditionalForm]"<>","<>"ToString[ToString[\"@a = \",TraditionalForm]<>ToString[\"#c@b + #d\"/\"@b\",TraditionalForm],TraditionalForm]"<>","<>"ToString[\", where @a is the weekly salary in dollars (per person) and @b is the number of employees working for the company\",TraditionalForm]"<>"}]"},


(*a*)
{"Column[{ToString[\"FGHJKLabc) Find the weekly pay when there are #b employees.\"]"<>","<>"ToString[\"\",TraditionalForm]}]"}

,

(*b*)
{"Column[{ToString[\"FGHJKLabc) Find the number of employees if the weekly salary is $#e.\"]"<>","<>"ToString[\"\",TraditionalForm]}]"} 
},InputForm]<>";\n ";

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


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

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

{aa,bb}=nLetters[{"a","y"},2]/.{"l"->"L","o"->"z"}; 

c=ToString@RandomInteger[{400,600}];
b=ToString@(RandomInteger[{2,6}]*10);
(*sol*)a=ToString@(RandomInteger[{100,200}]+ ToExpression[c]);
d=ToString@(ToExpression[b]*(ToExpression[a] - ToExpression[c]));


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

(*e=ToString@10000;*)
e =ToString[NSolve[P>ToExpression[a] && n<ToExpression[b] && P==(ToExpression[c]*n+ToExpression[d])/n,{n,P},Integers][[-1]][[2]][[2]]];
vars={aa,bb,c,d,e,b,a};
sol=a;

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


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



vars={aa,bb,c,d,e,b,a};
sol=ToString[NSolve[P>ToExpression[a] && n<ToExpression[b] && P==(ToExpression[c]*n+ToExpression[d])/n,{n,P},Integers][[-1]][[1]][[2]]];

partb={StringReplace[text, {"#c"->c, "#d"->d, "@a"->aa,"#b"->b, "@b"->bb, "#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[{x,b,c,d,a,e, aa,bb,cc,dd,ee, ff, gg, hh, ii, jj, text,list,sol, body={},vars=ertyuiop,options=ERTYUIOP, varsa, varsb, varsc,g,h},





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


{aa,bb,c,d,e,b,a}=varsa;




body={
{ToString[Column[{
options[[1]]<>": \n"<>aa<>" = "<>ToString[((c<>"("<>b<>") + "<>d)/b),TraditionalForm]<>
"\n"<>aa<>" = "<>ToString[(1/b)ToString[ToExpression[c]*ToExpression[b],TraditionalForm]<>" + "<>d,TraditionalForm]<>
"\n"<>aa<>" = "<>ToString[((ToExpression[c]*ToExpression[b]+ ToExpression[d])/b),TraditionalForm]<>
"\n"<>aa<>" = "<>a<>"\n"
,

(*b*)
{aa,bb,c,d,e,b,a}=varsb; 
sol=ToString[NSolve[P>ToExpression[a] && n<ToExpression[b] && P==(ToExpression[c]*n+ToExpression[d])/n,{n,P},Integers][[-1]][[1]][[2]]];
options[[2]]<>": \n"<>e<>" = "<>ToString[((c<>bb<>" + "<>d)/bb),TraditionalForm]<>
"\n"<>e<>bb<>" = "<>ToString[c<>bb<>" + "<>d,TraditionalForm]<>
"\n"<>e<>bb<>" - "<>c<>bb<>" = "<>d<>
"\n"<>ToString[ToExpression[e]-ToExpression[c],TraditionalForm]<>bb<>" = "<>d<>
"\n"<>bb<>" = "<>sol
}],TraditionalForm]

}, 
{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={ 
{options[[1]]<>": \nIdentify which variables are given and which is the unknown.", 
options[[2]]<>": \nIdentify which variables are given and which is the unknown."
},
{Null ,Null}
};

Panel[Grid[Transpose[body]]]

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

data1="\n"<>"textfghjkl:="<>ToString[
{"Column[{ToString[\"fghjkl. The formula for the revenue of a certains businesss is given as:\",TraditionalForm]"<>","<>"ToString[ToString[\"@a = \",TraditionalForm]<>ToString[ToString[@b*Sqrt[@c],TraditionalForm]/\"#d\",TraditionalForm],TraditionalForm]"<>","<>
"ToString[\", where @a represents the revenue in millions of dollars in year number @c and @b represents the amount of cash available in millions of dollars when the company was originally purchased. If @a=#a and @b=#b, solve for @c.\",TraditionalForm]"<>"}]"},InputForm]<>";\n ";

data2="listfghjkl:="<>


ToString[{""

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

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

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


text=qRandList[textfghjkl];

x=RandomInteger[{5,9}];
c=ToString@(x*x);
d=ToString@RandomInteger[{2,6}];
b=ToString@(ToExpression[d]*RandomInteger[{4,9}]);
a=ToString@((ToExpression[b]*x)/ToExpression[d]);

{aa,bb,cc,dd}=nLetters[{"a","y"},4]/.{"l"->"L","o"->"z"}; 
x=ToString[x];
(*{a,b,c,d}=ToString/@{RandomInteger[{4,10}],RandomInteger[{4,10}],RandomInteger[{4,10}],RandomInteger[{2,3}]};*)
vars={aa,bb,cc,dd, a,b,c,d,x};
sol=c;



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

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

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


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



{aa,bb,cc,dd, a,b,c,d,x}=vars[[1]];





body={
{
a<>" = "<>ToString[((b<>ToString[(Sqrt[cc]),TraditionalForm])/d),TraditionalForm],
ToString[ToExpression[a]*ToExpression[d],TraditionalForm]<>" = "<>b<>ToString[(Sqrt[cc]),TraditionalForm],
x<>" = "<>ToString[(Sqrt[cc]),TraditionalForm],
ToString[((ToString[x,TraditionalForm])^2),TraditionalForm]<>" = "<>cc,
cc<>" = "<>c
},
{Null ,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},


body={
{"Identify which variables are given and which is the unknown.",
"Use cross multiplication (a/b) = (x/c) ⟹ x = (ac/b)"},
{Null ,Null}
};

Panel[Grid[Transpose[body]]]

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

data1="\n"<>"textfghjkl:="<>ToString[
{"Column[{ToString[\"fghjkl. \"<>Capitalize[IntegerName[ToExpression[#a]]]<>\" chocolate bars and \"<>IntegerName[ToExpression[#b]]<>\" ice-cream cones cost $#c. \"<>Capitalize[IntegerName[ToExpression[#d]]]<>\" chocolate bars and \"<>IntegerName[ToExpression[#e]]<>\" ice-cream cost $#f. Find the cost of @a.\",TraditionalForm]"<>","<>"ToString[\" \"]"<>"}]"},InputForm]<>";\n ";

data2="listfghjkl:="<>


ToString[{"a chocolate bar","an ice-cream cone"

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

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

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


text=qRandList[textfghjkl];

aa=RandomChoice[listfghjkl];

(*{a,b,d,e}=ToString/@RandomInteger[{2,10},4];
{c,f}=ToString/@RandomReal[{1,4},2];*)
x=ToString@(RandomInteger[{50,80}]*0.01);
y=ToString@(RandomInteger[{70,99}]*0.01);
{a,b}=RandomInteger[{2,7},2];
{d,e}={a,b};
While[{d,e}=={a,b},{d,e}=RandomInteger[{2,7},2]];
{a,b,d,e}=ToString/@{a,b,d,e};
c=ToString@(ToExpression[a]*ToExpression[x]+ToExpression[b]*ToExpression[y]);
f=ToString@(ToExpression[d]*ToExpression[x]+ToExpression[e]*ToExpression[y]);

vars={ a,b,c,d,e,f,x,y,aa};
sol=x;
If[aa==="a chocolate bar",
sol=x,
sol=y];



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

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

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


solution4=data1<>data2<>ToString[Hold[Module[{aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,a,b,c,d,e,f,p,x,y,ad,ae,af,da,db,dc,text,list,sol, body={},vars=ertyuiop},



{a,b,c,d,e,f,x,y,aa}=vars[[1]];

sol=ToString[{ToExpression[x],ToExpression[y]},TraditionalForm];

da=ad=ToString[ToExpression[d]*ToExpression[a]];
db=ToString[ToExpression[d]*ToExpression[b]];
dc=ToString[ToExpression[d]*ToExpression[c]];
ae=ToString[ToExpression[e]*ToExpression[a]];
af=ToString[ToExpression[f]*ToExpression[a]];

body={
{
"Let x represent cost per chocolate bars",
"Let y represent cost per ice cream cone",
ToString[({{\[Piecewise], ({{a<>" x + "<>b<>" y = "<>c, "····· 1"}, {d<>" x + "<>e<>" y = "<>f, "····· 2"}})}}),TraditionalForm],
tv[{"Method 1",
"Method of Substitution\n"<>ToString[({{\[Piecewise], ({{"x = "<>ToString[(("1")/a),TraditionalForm]<>"(-"<>b<>" y + "<>c<>")", "····· 1"}, {d<>" x + "<>e<>" y = "<>f, "····· 2"}})}}),TraditionalForm]<>"\nSubstitute 1 into 2\n"<>
d<>"["<>ToString[(("1")/a),TraditionalForm]<>"(-"<>b<>" y + "<>c<>")] + "<>e<>" y = "<>f<>"····· × "<>a<>"\n"<>
d<>"(-"<>b<>" y + "<>c<>") + "<>ToString[ToExpression[e]*ToExpression[a],TraditionalForm]<>" y = "<>ToString[ToExpression[f]*ToExpression[a],TraditionalForm]<>"\n"<>
"-"<>ToString[ToExpression[d]*ToExpression[b],TraditionalForm]<>" y + "<>ToString[ToExpression[d]*ToExpression[c],TraditionalForm]<>" + "<>ToString[ToExpression[e]*ToExpression[a],TraditionalForm]<>" y = "<>ToString[ToExpression[f]*ToExpression[a],TraditionalForm]<>"\n"<>
ToString[ToExpression[e]*ToExpression[a],TraditionalForm]<>" y - "<>ToString[ToExpression[d]*ToExpression[b],TraditionalForm]<>" y = "<>ToString[ToExpression[f]*ToExpression[a],TraditionalForm]<>" - "<>ToString[ToExpression[d]*ToExpression[c],TraditionalForm]<>"\n"<>ToString[ToExpression[e]*ToExpression[a]-ToExpression[d]*ToExpression[b],TraditionalForm]<>" y = "<>ToString[ToExpression[f]*ToExpression[a]-ToExpression[d]*ToExpression[c],TraditionalForm]<>
"\ny = "<>y<>"\n\n"<>
"x = "<>ToString[(("1")/a),TraditionalForm]<>"((-"<>b<>")("<>y<>") + "<>c<>")\n"<>
"x = "<>ToString[(("1")/a),TraditionalForm]<>"(-"<>ToString[ToExpression[b]*ToExpression[y],TraditionalForm]<>" + "<>c<>")\n"<>
"x = "<>ToString[(("1")/a),TraditionalForm]<>"("<>ToString[-ToExpression[b]*ToExpression[y]+ ToExpression[c],TraditionalForm]<>")\n"<>
"x = "<>x
,
"Method 2",
"Method of Elimination\n"<>ToString[({{\[Piecewise], ({{a<>" x + "<>b<>" y = "<>c, "····· 1 ×"<>d}, {d<>" x + "<>e<>" y = "<>f, "····· 2 ×"<>a}})}}),TraditionalForm]<>"\n"<>ToString[({{\[Piecewise], ({{da<>" x + "<>db<>" y = "<>dc, "····· 1 "}, {ad<>" x + "<>ae<>" y = "<>af, "····· 2 "}})}}),TraditionalForm]<>"\nEliminate x by\n Substracting 1 and 2\n"<>
db<>" y - "<>ae<>" y = "<>dc<>" - "<>af<>"\n"<>
ToString[ToExpression[db] - ToExpression[ae],TraditionalForm]<>" y = "<>ToString[ToExpression[dc]-ToExpression[af],TraditionalForm]<>"\n"<>
"y = "<>y<>"\n\n"<>
a<>" x + "<>b<>"("<>y<>") = "<>c<>"\n"<>
a<>" x + "<>ToString[ToExpression[b]*ToExpression[y],TraditionalForm]<>" = "<>c<>"\n"<>
a<>" x = "<>c<>" - "<>ToString[ToExpression[b]*ToExpression[y],TraditionalForm]<>"\n"<>
a<>" x = "<>ToString[ToExpression[c]-ToExpression[b]*ToExpression[y],TraditionalForm]<>"\n"<>
"x = "<>x
,
"Method 3",
"Alternative Method of Elimination\n"<>

ToString[({{\[Piecewise], ({{a<>" x + "<>b<>" y = "<>c, "····· 1 ×"<>d}, {d<>" x + "<>e<>" y = "<>f, "····· 2 ×"<>a}})}}),TraditionalForm]<>"\n"<>ToString[({{\[Piecewise], ({{da<>" x + "<>db<>" y = "<>dc, "····· 1 "}, {ad<>" x + "<>ae<>" y = "<>af, "····· 2 "}})}}),TraditionalForm]<>"\n"<>
"Isolate "<>da<>" x\n"<>

ToString[({{\[Piecewise], ({{da<>" x = "<>dc<>" - "<>db<>" y", "····· 1 "}, {ad<>" x = "<>af<>" - "<>ae<>" y", "····· 2 "}})}}),TraditionalForm]<>"\n"<>
dc<>" - "<>db<>" y = "<>af<>" - "<>ae<>" y"<>"\n"<>
ae<>" y"<>" - "<>db<>" y = "<>af<>" - "<>dc<>"\n"<>
ToString[ToExpression[ae] - ToExpression[db],TraditionalForm]<>" y = "<>ToString[ToExpression[af] - ToExpression[dc],TraditionalForm]<>"\n"<>" y = "<>y<>"\n\n"<>
a<>" x + "<>b<>"("<>y<>") = "<>c<>"\n"<>
a<>" x + "<>ToString[ToExpression[b]*ToExpression[y],TraditionalForm]<>" = "<>c<>"\n"<>
a<>" x = "<>c<>" - "<>ToString[ToExpression[b]*ToExpression[y],TraditionalForm]<>"\n"<>
a<>" x = "<>ToString[ToExpression[c]-ToExpression[b]*ToExpression[y],TraditionalForm]<>"\n"<>
"x = "<>x
}],
"Answer:"<>
If[aa==="a chocolate bar",
x,
y]
},
{Null ,Null,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},


body={
{"Think System of Equations.",
"Solved by: ",
ToString[tv[{"Method 1","Method of Substitustion","Method 2","Method of Elimination","Method 3","Alternative Method of Elimination"}],TraditionalForm]},
{Null ,Null, Null}
};

Panel[Grid[Transpose[body]]]

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

data1="\n"<>"textfghjkl:="<>ToString[
{"Column[{ToString[\"fghjkl. There are #a bank managers and tellers combined in a branch. Assuming that each manager makes $#b per month and each teller makes $#c per month and the total paid out monthly is $#d, how many @a are there?\",TraditionalForm]"<>","<>"ToString[\" \"]"<>"}]"},InputForm]<>";\n ";

data2="listfghjkl:="<>


ToString[{"managers","tellers"

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

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

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


text=qRandList[textfghjkl];

aa=RandomChoice[listfghjkl];

(*{a,b,c,d}=ToString/@{RandomInteger[{20,40}],1000*RandomInteger[{5,10}],1000*RandomInteger[{2,4}], 100*RandomInteger[{100,200}]} *);
x=ToString@RandomInteger[{5,10}];
y=ToString@RandomInteger[{30,40}];
a=ToString@(ToExpression[x]+ToExpression[y]);
b=ToString@RandomInteger[{6000,8000}];
c=ToString@RandomInteger[{3000,4500}];
d=ToString@(ToExpression[b]*ToExpression[x]+ToExpression[c]*ToExpression[y]);
vars={ a,b,c,d,x,y};
If[aa==="managers",
sol=x,
sol=y];

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

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

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


solution5=data1<>data2<>ToString[Hold[Module[{aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,a,b,c,d,e,f,x,y,p, text,list,sol, body={},vars=ertyuiop},



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



body={
{ToString[tv[{"Method 1",
ToString[makeTextTable[{{"","# of people","salary","total salary"},{"Bank managers","x",b,b<>" x"},{"Tellers","y",c,c<>" y"},{"Total",a,"",d}}],TraditionalForm]<>"\n"<>
ToString[({{\[Piecewise], ({{"      x + y = "<>a, "····· 1"}, {b<>" x + "<>c<>" y = "<>d, "····· 2"}})}}),TraditionalForm]<>"\n"<>ToString[tv[{"1","Method of Substitution\n"<>ToString[({{\[Piecewise], ({{"      y = "<>a<>" - x", "····· 1"}, {b<>" x + "<>c<>" y = "<>d, "····· 2"}})}}),TraditionalForm]<>"\nSubstitute 1 into 2\n"<>
b<>" x + "<>c<>"("<>a<>" - x)= "<>d<>"\n"<>
b<>" x + "<>ToString[ToExpression[c]*ToExpression[a],TraditionalForm]<>"-"<>c<>" x= "<>d<>"\n"<>
ToString[ToExpression[b] - ToExpression[c],TraditionalForm]<>" x = "<> ToString[ToExpression[d] - ToExpression[c]*ToExpression[a],TraditionalForm]<>"\n"<>"x = "<>x<>"\n\n"<>
"y = "<>a<>" - "<>x<>"\n"<>
"y = "<>y,
"2",
"Method of Elimination\nEliminate y\n"<>ToString[({{\[Piecewise], ({{"      x + y = "<>a, "····· 1 ×(-"<>c<>")"}, {b<>" x + "<>c<>" y = "<>d, "····· 2"}})}}),TraditionalForm]<>"\n"<>ToString[({{\[Piecewise], ({{"-"<>c<>" x -"<>c<>" y = "<>ToString[ToExpression[a]*ToExpression[c]], "····· 1 "}, {b<>" x + "<>c<>" y = "<>d, "····· 2"}})}}),TraditionalForm]<>"\n"<>ToString[ToExpression[b] - ToExpression[c],TraditionalForm]<>" x = "<> ToString[ToExpression[d] - ToExpression[c]*ToExpression[a],TraditionalForm]<>"\n"<>"x = "<>x<>"\n\n"<>
x<>" + y = "<>a<>"\n"<>
"y = "<>a<>" - "<>x<>"\n"<>
"y = "<>y,
"3",
"Alternative Method of Elimination\n"<>
ToString[({{\[Piecewise], ({{"      x + y = "<>a, "····· 1 ×"<>c}, {b<>" x + "<>c<>" y = "<>d, "····· 2"}})}}),TraditionalForm]<>"\n"<>ToString[({{\[Piecewise], ({{c<>" x + "<>c<>" y = "<>ToString[ToExpression[a]*ToExpression[c]], "····· 1 "}, {b<>" x + "<>c<>" y = "<>d, "····· 2"}})}}),TraditionalForm]<>"\nIsolate "<>c<>" y\n"<>
ToString[({{\[Piecewise], ({{c<>" y = "<>ToString[ToExpression[a]*ToExpression[c]]<>" - "<>c<>" x ", "····· 1 "}, {c<>" y = "<>d<>" - "<>b<>" x ", "····· 2"}})}}),TraditionalForm]<>"\n"

<>ToString[ToExpression[a]*ToExpression[c]]<>" - "<>c<>" x  = "<>d<>" - "<>b<>" x \n"<>
b<>" - "<>c<>" x  = "<>d<>" - ( "<>ToString[ToExpression[a]*ToExpression[c]]<>" )\n"<>
ToString[ToExpression[b] - ToExpression[c],TraditionalForm]<>" x = "<> ToString[ToExpression[d] - ToExpression[c]*ToExpression[a],TraditionalForm]<>"\n"<>"x = "<>x<>"\n\n"<>
x<>" + y = "<>a<>"\n"<>
"y = "<>a<>" - "<>x<>"\n"<>
"y = "<>y

}],TraditionalForm],

"Method 2",
ToString[makeTextTable[{{"","# of people","salary","total salary"},{"Bank managers","x",b,b<>" x"},{"Tellers",a<>" - x",c,c<>"("<>a<>" - x)"},{"Total",a,"",d}}],TraditionalForm]<>"\n"<>
ToString[b<>" x + "<>c<>"("<>a<>" - x) = "<>d,TraditionalForm]<>"\n"<>ToString[b<>" x + "<>ToString[ToExpression[c]*ToExpression[a],TraditionalForm]<>" - "<>ToString[ToExpression[c],TraditionalForm]<>" x = "<>d,TraditionalForm]<>"\n"<>ToString[ToString[ToExpression[b]-ToExpression[c],TraditionalForm]<>" x = "<>ToString[ToExpression[d] - ToExpression[c]*ToExpression[a],TraditionalForm],TraditionalForm]<>"\n"<>"x = "<>x<>"\n\nBank managers:"<>x<>"\n"<>"Tellers:"<>a<>" - "<>x<>" = "<>y
}],TraditionalForm],
""
},
{Null ,Null}

};

Panel[Grid[Transpose[body]]]

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


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


body={
{"Think \"Unit cost number of items and total revenue\" table",
ToString[tv[{"Method 1",
"Set up systems of equations\nSolved by:\n"<>ToString[tv[{"1","Method of Substitution","2","Method of Elimination","3","Alternative Method of Elimination"}],TraditionalForm],
"Method 2",
"Set up one variable algebraic equation\nSolved by:\nExpand and collect like terms.\nVariable on one side = Number on the other side"}],TraditionalForm],
""},
{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";
proc4=ToString[{ToString[Hold[Module[{},"level"]],InputForm],variation4,hint4,solution4},InputForm]<>";\n";
proc5=ToString[{ToString[Hold[Module[{},"level"]],InputForm],variation5,hint5,solution5},InputForm]<>";\n";

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

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

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

CDF AREA

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