w={6.026,6.135,6.139,6.131,6.043,6.02,6.148,6.152,6.085,6.029,6.013,6.166,5.993,6.122,6.11,5.99,6.075,6.147}
Length[w]

(Mean[w] - 6.07)/(StandardDeviation[w]/Sqrt[18])

1-0.8701

StandardDeviation[{6.029,6.089,6.056,6.051,6.11,6.068,6.098,6.096,6.011,6.009,6.033,6,5.995,5.990,6.11,5.99,5.955,5.922}]

funAnna[]=Module[{},
a1=ToString@(N[RandomInteger[{6000,6200}]/1000]);
f=ToExpression@a1-0.09;
g=ToExpression@a1+0.09;
c=ToString/@(RandomSample[Range[f*1000,g*1000],18]/1000);
a=ToString@Mean[ToExpression/@c];
b=ToString@(N[Floor[(ToExpression@a - 0.01)*100]/100]);
sd=StandardDeviation[ToExpression/@c];
d=ToString@(N[(ToExpression@a-ToExpression@b)/(sd/Sqrt[18])])
]

For[i=1,i≤100000,i++;
index=funAnna[];
If[index≥1.74,index]
]

a=ToString@(N[RandomInteger[{6000,6070}]/1000]);
b=ToString@(N[Floor[(ToExpression@a - 0.01)*100]/100]);
f=ToExpression@a-0.09;
g=ToExpression@a+0.09;
Range[f*1000,g*1000];
c=RandomSample[Range[f*1000,g*1000],18]/1000;
d=StandardDeviation[c];
t=(ToExpression@a-ToExpression@b)/(d/Sqrt[18])

a1=ToString@RandomChoice[{1-0.90, 1-0.95, 1-0.975, 1-0.99, 1-0.995, 1-0.999}]

sol2=NSolve[CDF[StudentTDistribution[17],1.08]==1- (ToExpression@x),{x}, Reals]
t=x/.sol2[[1]]

ToString@(N[Ceiling[N[IntegerPart[t*10000]/100]+1]/100])

(*t2=N[IntegerPart[t*10000]/10000];
If[(IntegerPart[t*100000]-(IntegerPart[t*10000]*10))≥ 5,t2=t2+0.0001,t2=t2]*)

sol={t}

t=NSolve[CDF[StudentTDistribution[17],1.08]==1- (ToExpression@x),{x}, Reals]
a=ToString@(N[Ceiling[N[IntegerPart[t*10000]/100]+1]/100])

sol2=NSolve[CDF[StudentTDistribution[17],ToExpression@d]==1- (ToExpression@x),{x}, Reals]
t=x/.sol2[[1]]
a=ToString@(N[Ceiling[N[IntegerPart[t*10000]/100]+1]/100])

h=ToString/@{1,2,3,4,5,6}
s=ToExpression/@h
Head[s[[4]]]

(*anna*)

a=ToString@(N[RandomInteger[{6000,6200}]/1000])
b=ToString@(N[Floor[(ToExpression@a - 0.01)*100]/100])
f=ToExpression@a-0.09;
g=ToExpression@a+0.09;
Range[f*1000,g*1000];
c=ToString/@(RandomSample[Range[f*1000,g*1000],18]/1000)
sd=StandardDeviation[ToExpression/@c]
d=ToString@(N[(ToExpression@a-ToExpression@b)/(sd/Sqrt[18])])

sol2=NSolve[CDF[StudentTDistribution[17],ToExpression@1.0848603]==1- (ToExpression@x),{x}, Reals]
t=x/.sol2[[1]]
a1=ToString@(N[Ceiling[N[IntegerPart[t*10000]/100]+1]/100])
c1=ToString@(ToExpression@a1- 0.05)
e1=ToString@(ToExpression@c1 - 0.03)

(*{
{StringReplace["At α=#a there is sufficient evidence to conclude that the population mean weight of the chocolate bars is #b ounces.", { "#a"->a1,"#b"->b,"#c"->c1,"#d"->d,"#e"->e1}],
{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["At α=#c there is sufficient evidence to conclude that the population mean weight of the chocolate bars is greater than #b ounces.",{ "#a"->a1,"#b"->b,"#c"->c1,"#d"->d,"#e"->e1}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["At α=#e there is sufficient evidence to conclude that the population mean weight of the chocolate bars is greater than #b ounces.",{ "#a"->a1,"#b"->b,"#c"->c1,"#d"->d,"#e"->e1}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["At α=#a there is sufficient evidence to conclude that the population mean weight of the chocolate bars is greater than #b ounces.",{ "#a"->a1,"#b"->b,"#c"->c1,"#d"->d,"#e"->e1}],{"\"T\"","\"true\"","\"TRUE\""}}
}*)

{x/.NSolve[CDF[NormalDistribution[0,1],x]==1- (1-ToExpression@"0.99"),{x}, Reals][[1]]}

(RandomChoice[{1,2}]*{100,RandomSample[Range[90,96],1][[1]]})

{b,c}=ToString/@(RandomChoice[{1,2}]*{100,RandomSample[Range[90,96],1][[1]]})

jkl=x/.NSolve[CDF[NormalDistribution[0,1],2.520504151]==1- (1-x),{x}, Reals][[1]]
1-jkl

dfg={6.027,6.151,6.146,6.069,6.132,6.05,6.134,6.07,6.196,6.122,6.133,6.036,6.057,6.031,6.186,6.051,6.107,6.026};
Mean[dfg]
StandardDeviation[dfg]

a=ToString@(N[RandomInteger[{6000,6200}]/1000])
b=ToString@(N[Floor[(ToExpression@a - 0.01)*100]/100])
f=ToExpression@a-0.09
g=ToExpression@a+0.09
Range[f*1000,g*1000];
c=ToString/@(RandomSample[Range[f*1000,g*1000],18]/1000)
sd=StandardDeviation[ToExpression/@c]
d=ToString@(N[(ToExpression@a-ToExpression@b)/(sd/Sqrt[18])])

z=N[
((ToExpression@"94"/ToExpression@"100")-ToExpression@"0.85")/Sqrt[(ToExpression@"0.85" * (1-ToExpression@"0.85")/(ToExpression@"100"))]
]
t=x/.NSolve[CDF[NormalDistribution[0,1],z]==1- (1-x),{x}, Reals][[1]]
t=1-t
t=N[(IntegerPart[t*10000]/100)]
a1=ToString@N[0.5*t]
b1=ToString@(N[t+RandomChoice[{2,3}]])
c1=ToString@(N[t+RandomChoice[{4,5,6}]])
d1=ToString@(N[t+RandomChoice[{10,11,12}]])

μ=0;σ=1;
b="1.33";
μ

Show[
Plot[Evaluate@Table[PDF[NormalDistribution[μ,σ],x],{μ,{μ0}}],{x,-a*σ+μ0,a*σ+μ0},AxesOrigin->{μ0,0},Ticks->{{μ2,{conf,conf,{0.6,0},Directive[Red,Dashed]},μ1,μ0,{μ0-conf+μ0,μ0-conf+μ0,{0.6,0},Directive[Red,Dashed]}},None},
Filling->Axis,PlotStyle->LightGray, Axes->{True,False},ImageSize->400,PlotRange->Full,TicksStyle->Directive[Orange,8],PlotLegends->Column@{"\!\(\*SubscriptBox[\(H\), \(0\)]\):μ="<>ToString[μ0],"\!\(\*SubscriptBox[\(H\), \(1\)]\):μ≠"<>ToString[μ0]}],

Plot[Evaluate@Table[PDF[NormalDistribution[μ,σ],x],{μ,{μ0}}],{x,μ0-conf+μ0,a*σ+μ0},AxesOrigin->{μ0,0},Filling->Axis,PlotStyle->Red, Axes->False,ImageSize->400,PlotRange->Full],

Plot[Evaluate@Table[PDF[NormalDistribution[μ,σ],x],{μ,{μ0}}],{x,-a*σ+μ0,conf},AxesOrigin->{μ0,0},Filling->Axis,PlotStyle->Red, Axes->False,ImageSize->400,PlotRange->Full],

Graphics[{Dashed,Line[{{μ0,0}, {μ0,PDF[NormalDistribution[μ0,σ],μ0]}}],Black,Text["\!\(\*FractionBox[\(α\), \(2\)]\)",{μ0-conf+μ0+4, PDF[NormalDistribution[μ0,σ],μ0]/9}],Text["\!\(\*FractionBox[\(α\), \(2\)]\)",{conf-2, PDF[NormalDistribution[μ0,σ],μ0]/9}]}] ],

μ=0;σ=1.5;
d="1.4";
a="1";
σ=1.5;
g1=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,7},Filling->Axis,PlotLabel->Column[{Style["Normal Distribution",Bold],Grid[{{"(Subscript[Z, STAT]) = \!\(\*FractionBox[\(\(\\ \)\(\(p\)\(\\ \)\(-\)\(\\ \)\(π\)\(\\ \)\)\), SqrtBox[FractionBox[\(π \((1 - π)\)\), \(n\)]]]\) = "<>ToString[a]}},Frame->All],""},Alignment->Center], PlotRange->Full,AxesOrigin->{0,0},Ticks->{{-ToExpression@a,ToExpression@a},None}];
g2=Plot[PDF[NormalDistribution[μ,σ],x],{x,ToExpression@a,7},Filling->Axis, PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Directive[Orange], FillingStyle->{Orange}];
g3=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,-ToExpression@a},Filling->Axis, PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Directive[Orange], FillingStyle->{Orange}];
Show[g1,g2,g3,Graphics[{
Dashed,
Black,
Text[Style["p-value = "<>ToString@(ToExpression@e),Small,Bold],{5,0.15}],
Arrow[BezierCurve[{{5,0.13},{5,0.05},{ToExpression@a+1,0.01}}]],
Arrow[BezierCurve[{{3,0.15},{-ToExpression@a,0.12},{-ToExpression@a-1,0.01}}]]
}],ImageSize->400]

list=RandomChoice@{

{StringReplace["At α=#a there is sufficient evidence to conclude that the population mean weight of the chocolate bars is #b ounces.", { "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],
{"\"False\"","\"false\"","\"FALSE\"","\"F\""},a},

{StringReplace["At α=#c there is sufficient evidence to conclude that the population mean weight of the chocolate bars is greater than #b ounces.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""},c},

{StringReplace["At α=#e there is sufficient evidence to conclude that the population mean weight of the chocolate bars is greater than #b ounces.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""},e},

{StringReplace["At α=#a there is sufficient evidence to conclude that the population mean weight of the chocolate bars is greater than #b ounces.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],{"\"T\"","\"true\"","\"TRUE\""},a}
}

list[[1;;2]]

NSolve[CDF[StudentTDistribution[17],ToExpression@"1.09"]==1- (ToExpression@x),{x}, Reals]

h1=NSolve[CDF[StudentTDistribution[17],ToExpression@"1.09"]==1- (ToExpression@x),{x}, Reals]
h=x/.h1[[1]]

b1=NSolve[CDF[StudentTDistribution[17],x]==1- (ToExpression@"0.15"),{x}, Reals]
a1=x/.b1[[1]]

e="0.067";
g1=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,7},Filling->Axis,PlotLabel->Column[{Style["Normal Distribution",Bold]},Alignment->Center], PlotRange->Full,AxesOrigin->{0,0},Ticks->{{-ToExpression@d,ToExpression@d},None}];
g2=Plot[PDF[NormalDistribution[μ,σ],x],{x,ToExpression@a,7},Filling->Axis, PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Directive[Black,Dashed], FillingStyle->{Orange}];
g3=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,-ToExpression@a},Filling->Axis, PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Directive[Black,Dashed], FillingStyle->{Orange}];
Show[g1,g2,g3,Graphics[{
Dashed,
Black,Line[{{ToExpression@a,0},{ToExpression@a,0.25}}],
Line[{{-ToExpression@a,0},{-ToExpression@a,0.25}}],
Text[Style["p-value = "<>ToString@(2*ToExpression@e),Small,Bold],{5,0.09}],
Arrow[BezierCurve[{{5,0.08},{5,0.05},{ToExpression@a+1,0.01}}]],
Arrow[BezierCurve[{{3.5,0.09},{-ToExpression@a-1,0.05},{-ToExpression@a-1,0.01}}]]
}],ImageSize->400]

{μ,σ}={0,1}
c="0.05";
d="1.65";
g1=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,7},Filling->Axis,PlotLabel->Column[{Style["Normal Distribution",Bold],"α = "<>ToString@c,""},Alignment->Center], PlotRange->Full,AxesOrigin->{0,0},Ticks->{{ToExpression@d},{None}}];
g2=Plot[PDF[NormalDistribution[μ,σ],x],{x,ToExpression@d,7},Filling->Axis, PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green, FillingStyle->{Green}];
Show[g1,g2,Graphics[{
Dashed,Red,Line[{{-7,0.2},{ToExpression@d,0.2}}],Text[Style["Do not reject (Subscript[H, 0])",Medium,Bold],{-3,0.22}],
Green,Line[{{ToExpression@d,0.2},{7,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{5,0.22}],
Black,Line[{{ToExpression@d,0},{ToExpression@d,0.22}}],
Text[Style["(Subscript[Z, STAT]) > "<>ToString@d,Medium,Bold],{5,0.1}],
Text[Style["(Subscript[Z, STAT]) < "<>ToString@d,Medium,Bold],{-3,0.1}]
}],ImageSize->400]

a=ToString@(RandomSample[Range[80,88],1][[1]])
{b,c}=ToString/@({100,RandomSample[Range[90,96],1][[1]]})

d=ToString@(N[(ToExpression@a )/100])
z=N[((ToExpression@c/ToExpression@b)-ToExpression@d)/(Sqrt[(ToExpression@d*(1-ToExpression@d))/(ToExpression@b)])]
t=x/.NSolve[CDF[NormalDistribution[0,1],z]==1- (1-x),{x}, Reals][[1]]
t=1-t
t=N[(IntegerPart[t*10000]/100)]
a1=ToString@N[0.5*t]
b1=ToString@(N[t+RandomChoice[{2,3}]])
c1=ToString@(N[t+RandomChoice[{4,5,6}]])
d1=ToString@(N[t+RandomChoice[{10,11,12}]])
e=ToString@0;
(* For any String for sol we need to double quote or some confusing bug shows up*)
list={

{StringReplace["The null hypothesis would not be rejected if a #a% probability of committing a Type I error is allowed.", { "#a"->a1,"#b"->b1,"#c"->c1,"#d"->d1,"#e"->e}],
{"\"T\"","\"true\"","\"TRUE\""}},

{StringReplace["The null hypothesis would not be rejected if a #b% probability of committing a Type I error is allowed.",{ "#a"->a1,"#b"->b1,"#c"->c1,"#d"->d1,"#e"->e}],{"\"T\"","\"true\"","\"TRUE\""}},

{StringReplace["The null hypothesis would not be rejected if a #c% probability of committing a Type I error is allowed.",{ "#a"->a1,"#b"->b1,"#c"->c1,"#d"->d1,"#e"->e}],{"\"T\"","\"true\"","\"TRUE\""}},

{StringReplace["The null hypothesis would not be rejected if a #d% probability of committing a Type I error is allowed.",{ "#a"->a1,"#b"->b1,"#c"->c1,"#d"->d1,"#e"->e}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}}
}

2.1829/100*2

0.4747/100*2

18.6183/100*2

a=ToString@(RandomSample[Range[80,88],1][[1]])
{b,c}=ToString/@({100,RandomSample[Range[90,96],1][[1]]})

d=ToString@(N[(ToExpression@a )/100])

a="87"
b="100"
c="90"
ans=0.0191
d=ToString@(N[(ToExpression@a )/100])
z=N[((ToExpression@c/ToExpression@b)-ToExpression@d)/(Sqrt[(ToExpression@d*(1-ToExpression@d))/(ToExpression@b)])]
t=x/.NSolve[CDF[NormalDistribution[0,1],z]==1- (1-x),{x}, Reals][[1]]
e=ToString[2*(1-t)]
Abs[ans-ToExpression@e]
If[Abs[ans-ToExpression@e]<0.00001, 1, 0]