uses crt;
var ten:string;
dai,rong,canh,a,b,c,day,cao,h,s,p:real;
begin
clrscr;
repeat
write('Nhap ten hinh ban muon tinh dien tich:'); readln(ten);
until (ten='chu nhat') or (ten='vuong') or (ten='tam giac') or (ten='binh hanh') or (ten='thang');
case ten of
'chu nhat':
begin
repeat
write('Nhap chieu dai hinh chu nhat:'); readln(dai);
write('Nhap chieu rong hinh chu nhat:'); readln(rong);
until (dai>0) and (rong>0) and (dai>rong);
s:=dai*rong;
writeln('Dien tich hinh chu nhat la: ',s:4:2);
end;
'vuong':
begin
repeat
write('Nhap do dai canh hinh vuong:'); readln(canh);
until canh>0;
s:=sqr(canh);
writeln('Dien tich hinh vuong la: ',s:4:2);
end;
'tam giac':
begin
repeat
write('Nhap canh thu nhat:'); readln(a);
write('Nhap canh thu hai:'); readln(b);
write('Nhap canh thu ba:'); readln(c);
until (a>0) and (b>0) and (c>0) and (a+b>c) and (a+c>b) and (b+c>a);
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln('Dien tich hinh tam giac la: ',s:4:2);
end;
'binh hanh':
begin
repeat
write('Nhap chieu cao cua hinh binh hanh:'); readln(cao);
write('Nhap chieu dai day cua hinh binh hanh:'); readln(day);
until (cao>0) and (day>0);
s:=day*cao;
writeln('Dien tich hinh binh hanh la: ',s:4:2);
end;
'thang':
begin
repeat
write('Nhap day thu nhat:'); readln(a);
write('Nhap day thu hai:'); readln(b);
write('Nhap chieu cao:'); readln(h);
until (a>0) and (b>0) and (h>0);
s:=(a+b)/2*h;
writeln('Dien tich hinh thang la: ',s:4:2);
end;
end;
readln;
end.