function [ Decision, tval, pval, CL_lower, CL_upper ] = t_one_mean( mu, alpha, xbar, sd, n, type )

tval=(xbar-mu)/(sd/sqrt(n));
if strcmpi(type,'T')
disp(['T-Test for One Sample, Two Tails, H0:mu=', num2str(mu), ' H1:mu~=', num2str(mu)])
pval=2*(1-tcdf(abs(tval),n-1));
if pval<alpha
Decision='Decision: Reject Null (H0)';
else
Decision='Decision: FTR Null (H0)';
end
CL_lower=xbar-tinv(1-alpha/2,n-1)*sd/sqrt(n);
CL_upper=xbar+tinv(1-alpha/2,n-1)*sd/sqrt(n);
elseif strcmpi(type,'R')
disp(['T-Test for One Sample, Right Tail, H0:mu=', num2str(mu), ' H1:mu>', num2str(mu)])
if (tval < 0)
pval=tcdf(abs(tval),n-1);
else
pval=1-tcdf(abs(tval),n-1);
end
if pval<alpha
Decision='Decision: Reject Null (H0)';
else
Decision='Decision: FTR Null (H0)';
end
CL_lower=xbar-tinv(1-alpha,n-1)*sd/sqrt(n);
CL_upper=Inf;
elseif strcmpi(type,'L')
disp(['T-Test for One Sample, Left Tail, H0:mu=', num2str(mu), ' H1:mu<', num2str(mu)])
if (tval > 0)
pval=tcdf(abs(tval),n-1);
else
pval=1-tcdf(abs(tval),n-1);
end
if pval<alpha
Decision='Decision: Reject Null (H0)';
else
Decision='Decision: FTR Null (H0)';
end
CL_lower=-Inf;
CL_upper=xbar+tinv(1-alpha,n-1)*sd/sqrt(n);
end
disp([' mu = ', num2str(mu)])
disp([' xbar = ', num2str(xbar)])
disp([' n = ', num2str(n)])
disp([' tval = ', num2str(tval)])
disp([' pval = ', num2str(pval)])
disp(['CL_lower = ', num2str(CL_lower)])
disp(['CL_upper = ', num2str(CL_upper)])
disp(Decision)
end