program tiendien;
uses crt;
var ss,sd,sc,tien,i,j:longint;
m,y:integer;
ch:char;
c3,t,c,d,h,tien1:longint;
hang,hang2,hang3,chuso,h1,h2:longint;
begin
repeat
clrscr;
textcolor(15);
write('Nhap thang, nam:'); readln(m,y);
write('Nhap chi so cong to dau:'); readln(sd);
write('Nhap chi so cong to cuoi:'); readln(sc);
if (sd<sc) and (sc-sd<=130000) then
begin
clrscr;
ss:=sc-sd;
gotoxy(2,2);write('Hoa don tien dien':44);
gotoxy(2,3);write('Thang ',m:2,' nam ',y:5);
gotoxy(2,4);write('Ten ho gia dinh: ');
readln;
gotoxy(1,1);
for i:=1 to 70 do write('-');
gotoxy(1,20);
for i:=1 to 70 do write('-');
gotoxy(1,5);
for i:=1 to 70 do write('-');
gotoxy(1,7);
for i:=1 to 70 do write('-');
gotoxy(1,9);
for i:=1 to 22 do write('-');
gotoxy(23,14);
for i:=23 to 70 do write('-');
gotoxy(23,16);
for i:=23 to 70 do write('-');
gotoxy(23,18);
for i:=23 to 70 do write('-');
for i:=1 to 19 do
begin
gotoxy(1,i);write('|');
gotoxy(70,i);write('|');
if i>4 then
begin
gotoxy(23,i);write('|');
gotoxy(50,i);write('|');
if i<17 then
begin
gotoxy(30,i);write('|');
gotoxy(42,i);write('|');
end;
end;
end;
for i:=5 to 9 do begin gotoxy(12,i);write('|'); end;
gotoxy(2,6);write('Chi so dau');
gotoxy(13,6);write('Chi so sau');
gotoxy(24,6);write('He so');
gotoxy(31,6);write('DN tieu thu');
gotoxy(43,6);write('Don gia');
gotoxy(51,6);write('Thanh tien':15);
gotoxy(1,8);
write('|',sd:10,'|',sc:10,'|','1|':7,ss:11,'|');
{ gotoxy(24,9); write('Tr.do:');}
if ss<=100 then tien:=ss*550;
if (ss>100) and (ss<=150) then tien:=100*550+(ss-100)*900;
if (ss>150) and (ss<=200) then tien:=100*550+50*900+(ss-150)*1210;
if (ss>200) and (ss<=300) then tien:=100*550+50*900+50*1210+(ss-200)*1340;
if (ss>300) and (ss<=400) then tien:=200*1100+100*1340+(ss-300)*1400;
if (ss>400) then tien:=200*1100+100*1340+100*1400+(ss-400)*1500;
if ss<= 300 then
begin
gotoxy(43,9); write(550:7);
if ss<=100 then begin gotoxy(31,9); write(ss:11);
gotoxy(51,9); write(ss*550:19);
end
else begin gotoxy(31,9); write(100:11);
gotoxy(51,9); write(100*550:19);
if ss>=150 then begin gotoxy(31,10); write(50:11); gotoxy(43,10); write(900:7);
gotoxy(51,10); write(900*50:19);
if ss>=200 then begin gotoxy(31,11); write(50:11); gotoxy(43,11); write(1210:7);
gotoxy(31,12); write(ss-200:11); gotoxy(43,12); write(1340:7);
gotoxy(51,11); write(50*1210:19);
gotoxy(51,12); write((ss-200)*1340:19);
end
else begin gotoxy(31,11); write(ss-150:11); gotoxy(43,11); write(1210:7);
gotoxy(51,11); write((ss-150)*1210:19);
end;
end
else begin gotoxy(31,10); write(ss-100:11); gotoxy(43,10); write(900:7);
gotoxy(51,10); write((ss-100)*900:19);
end;
end;
end;
if ss>300 then
begin
gotoxy(31,9); write(200:11);
gotoxy(51,9); write(200*1100:19);
gotoxy(43,9); write(1100:7);
gotoxy(31,10); write(100:11);
gotoxy(51,10); write(100*1340:19);
gotoxy(43,10); write(1340:7);
if ss>=400 then begin gotoxy(31,11); write(100:11); gotoxy(43,11); write(1400:7);
gotoxy(31,12); write(ss-400:11); gotoxy(43,12); write(1500:7);
gotoxy(51,11); write(100*1400:19);
gotoxy(51,12); write((ss-300)*1400:19);
end
else begin gotoxy(31,11); write(ss-300:11); gotoxy(43,11); write(1400:7);
gotoxy(51,11); write((ss-300)*1400:19);
end;
end;
gotoxy(25,15); write('Cong |',288:11,'|','|':8,tien:19);
gotoxy(24,17); write('Thue GTGT (10%):');gotoxy(51,17); write(round(tien/10):19);
gotoxy(24,19); write('Tong cong tien thanh toan:');gotoxy(51,19); write(round(tien*11/10):19);
gotoxy(2,21);
write('So tien viet bang chu');
gotoxy(1,23);
for i:=1 to 70 do write('-');
for i:=20 to 23 do
begin
gotoxy(1,i); write('|');
gotoxy(70,i); write('|');
end;
tien:=(tien*11) div 10;
gotoxy(2,22);
tien1:=tien;
h1:=1000000;
repeat
hang:=tien div h1;
h2:=100;
hang2:=hang;
if hang2<>0 then
repeat
chuso:=hang2 div h2;
case chuso of
0:
begin
if (h2=100)and(hang3<>0) then write('khong tram ');
if ((h2=10)and(hang2 mod h2<>0))and((hang3<>0)or(hang div 100<>0)) then
write('linh ');
end;
1:if h2<> 10 then
write('mot ');
2:write('hai ');
3:write('ba ');
4:write('bon ');
5:
if h2=1 then
begin
if (hang mod 100)div 10 =0 then write('nam ')
else write('lam ');
end
else
write('nam ');
6:write('sau ');
7:write('bay ');
8:write('tam ');
9:write('chin ');
end;
if (h2=100)and (chuso<>0) then write('tram ');
if (h2=10)and (chuso<>0) then write('muoi ');
hang2:=hang2 mod h2;
h2:=h2 div 10;
until h2=0;
tien := tien mod h1;
if (hang<>0) then
begin
if h1=1000000 then write('trieu ');
if h1=1000 then write('nghin ');
end;
h1:=h1 div 1000;
hang3:=hang;
until h1=0;
write('dong');
end
else writeln('Nhap du lieu sai');
writeln;
gotoxy(1,25);
textcolor(15);
write('Co tinh tiep khong? (C/K) ');readln(ch);
until (ch='k') or (ch='K');
end.