{ SEMESTRA.PAS Copyright (c) Neznamy } { Simulator nakup v predajni. } { } { Datum:21.11.2007 http://www.trsek.com } program semestrlka; uses crt; var o,p,l:char; x,y,z,cena,m:real; c:byte; begin clrscr; cena:=0; writeln('kolko mas v penazenke'); readln(m); clrscr; repeat writeln('vyber si predajnu'); writeln('1 - CBA'); writeln('2 - Jednota'); writeln('3 - Potraviny'); writeln('-------------'); writeln('4 - Chod domov'); p:=readkey; if (p<>'1')and(p<>'2')and(p<>'3')and(p<>'4') then begin clrscr; end; {cba} if p='1' then begin clrscr; repeat writeln('predajna CBA:'); writeln('-------------'); writeln('vyber si oddelenie'); writeln('p / pecivo'); writeln('m / mliecne'); writeln('a / alkohol'); writeln('n / naspat'); o:=readkey; if (o<>'p')and(p<>'m')and(p<>'a')and(p<>'n') then begin clrscr; end; if o='p' then begin x:=28.50; y:=2.50; z:=3.00; clrscr; writeln('Oddelenie peciva'); writeln('----------------'); writeln('1/chleba: ',x:2:2); writeln('2/rozok: ',y:2:2); writeln('3/praclik: ',z:2:2); writeln('---------------'); writeln('chces si nieco kupit? -> stlac a'); l:=readkey; if l='a' then begin writeln('co?'); readln(c); if c=1 then begin writeln('zaplatit ',x:2:2); cena:=cena+x; end else if c=2 then begin clrscr; writeln('zaplatit ',y:2:2); cena:=cena+y; end else if c=3 then begin clrscr; writeln('zaplatit ',z:2:2); cena:=cena+z; end else if (c=12)or(c=21) then begin clrscr; writeln('zaplatit ',(x+y):2:2); cena:=cena+y+x; end else if (c=13) or (c=31) then begin clrscr; writeln('zaplatit ',(x+z):2:2); cena:=cena+x+z; end else if (c=23) or (c=32) then begin clrscr; writeln('zaplatit ',(y+z):2:2); cena:=cena+y+z; end else if (c=123) or (c=132) or (c=213) or (c=231) or (c=312) or (c=321) then begin clrscr; writeln('zaplatit ',(x+y+z):2:2); cena:=cena+y+x+z; end else writeln('zla volba'); writeln('**************'); end; end; if o='m' then begin x:=18.90; y:=32.50; z:=12.30; clrscr; writeln('Oddelenie mliecnych'); writeln('-------------------'); writeln('1/mlieko: ',x:2:2); writeln('2/syry: ',y:2:2); writeln('3/smotana:',z:2:2); writeln('---------------'); writeln('chces si nieco kupit? -> stlac a'); l:=readkey; if l='a' then begin writeln('co?'); readln(c); if c=1 then begin writeln('zaplatit ',x:2:2); cena:=cena+x; end else if c=2 then begin clrscr; writeln('zaplatit ',y:2:2); cena:=cena+y; end else if c=3 then begin clrscr; writeln('zaplatit ',z:2:2); cena:=cena+z; end else if (c=12)or(c=21) then begin clrscr; writeln('zaplatit ',(x+y):2:2); cena:=cena+y+x; end else if (c=13) or (c=31) then begin clrscr; writeln('zaplatit ',(x+z):2:2); cena:=cena+x+z; end else if (c=23) or (c=32) then begin clrscr; writeln('zaplatit ',(y+z):2:2); cena:=cena+y+z; end else if (c=123) or (c=132) or (c=213) or (c=231) or (c=312) or (c=321) then begin clrscr; writeln('zaplatit ',(x+y+z):2:2); cena:=cena+y+x+z; end else writeln('zla volba'); writeln('**************'); end; end; if o='a' then begin x:=99.90; y:=135.40; z:=199.90; clrscr; writeln('Oddelenie alkoholickych napojov'); writeln('-------------------------------'); writeln('1/0.5l vodka: ',x:2:2); writeln('2/0.7l borovicka:',y:2:2); writeln('3/0.7l citrus: ',z:2:2); writeln('-------------------'); writeln('chces si nieco kupit? -> stlac a'); l:=readkey; if l='a' then begin writeln('co?'); readln(c); if c=1 then begin writeln('zaplatit ',x:2:2); cena:=cena+x; end else if c=2 then begin clrscr; writeln('zaplatit ',y:2:2); cena:=cena+y; end else if c=3 then begin clrscr; writeln('zaplatit ',z:2:2); cena:=cena+z; end else if (c=12)or(c=21) then begin clrscr; writeln('zaplatit ',(x+y):2:2); cena:=cena+y+x; end else if (c=13) or (c=31) then begin clrscr; writeln('zaplatit ',(x+z):2:2); cena:=cena+x+z; end else if (c=23) or (c=32) then begin clrscr; writeln('zaplatit ',(y+z):2:2); cena:=cena+y+z; end else if (c=123) or (c=132) or (c=213) or (c=231) or (c=312) or (c=321) then begin clrscr; writeln('zaplatit ',(x+y+z):2:2); cena:=cena+y+x+z; end else writeln('zla volba'); writeln('********'); end; end; if (m<=cena) then begin clrscr; writeln('nedostatok penazi'); end else begin writeln('priebezna cena nakupov: ' ,cena:2:2); writeln; end; until (o='n')or(m<=cena); end; {Jednota} if p='2' then begin clrscr; repeat writeln('predajna Jednota:'); writeln('-----------------'); writeln('vyber si oddelenie'); writeln('p / pecivo'); writeln('m / mliecne'); writeln('a / alkohol'); writeln('n / naspat'); o:=readkey; if (o<>'p')and(p<>'m')and(p<>'a')and(p<>'n') then begin clrscr; end; if o='p' then begin x:=31.50; y:=1.90; z:=2.50; clrscr; writeln('Oddelenie peciva'); writeln('----------------'); writeln('1/chleba: ',x:2:2); writeln('2/rozok: ',y:2:2); writeln('3/praclik: ',z:2:2); writeln('---------------'); writeln('chces si nieco kupit? -> stlac a'); l:=readkey; if l='a' then begin writeln('co?'); readln(c); if c=1 then begin writeln('zaplatit ',x:2:2); cena:=cena+x; end else if c=2 then begin clrscr; writeln('zaplatit ',y:2:2); cena:=cena+y; end else if c=3 then begin clrscr; writeln('zaplatit ',z:2:2); cena:=cena+z; end else if (c=12)or(c=21) then begin clrscr; writeln('zaplatit ',(x+y):2:2); cena:=cena+y+x; end else if (c=13) or (c=31) then begin clrscr; writeln('zaplatit ',(x+z):2:2); cena:=cena+x+z; end else if (c=23) or (c=32) then begin clrscr; writeln('zaplatit ',(y+z):2:2); cena:=cena+y+z; end else if (c=123) or (c=132) or (c=213) or (c=231) or (c=312) or (c=321) then begin clrscr; writeln('zaplatit ',(x+y+z):2:2); cena:=cena+y+x+z; end else writeln('zla volba'); writeln('**************'); end; end; if o='m' then begin x:=19.50; y:=35.00; z:=8.90; clrscr; writeln('Oddelenie mliecnych'); writeln('-------------------'); writeln('1/mlieko: ',x:2:2); writeln('2/syry: ',y:2:2); writeln('3/smotana:',z:2:2); writeln('---------------'); writeln('chces si nieco kupit? -> stlac a'); l:=readkey; if l='a' then begin writeln('co?'); readln(c); if c=1 then begin writeln('zaplatit ',x:2:2); cena:=cena+x; end else if c=2 then begin clrscr; writeln('zaplatit ',y:2:2); cena:=cena+y; end else if c=3 then begin clrscr; writeln('zaplatit ',z:2:2); cena:=cena+z; end else if (c=12)or(c=21) then begin clrscr; writeln('zaplatit ',(x+y):2:2); cena:=cena+y+x; end else if (c=13) or (c=31) then begin clrscr; writeln('zaplatit ',(x+z):2:2); cena:=cena+x+z; end else if (c=23) or (c=32) then begin clrscr; writeln('zaplatit ',(y+z):2:2); cena:=cena+y+z; end else if (c=123) or (c=132) or (c=213) or (c=231) or (c=312) or (c=321) then begin clrscr; writeln('zaplatit ',(x+y+z):2:2); cena:=cena+y+x+z; end else writeln('zla volba'); writeln('**************'); end; end; if o='a' then begin x:=120.50; y:=150.00; z:=230.00; clrscr; writeln('Oddelenie alkoholickych napojov'); writeln('-------------------------------'); writeln('1/0.5l vodka: ',x:2:2); writeln('2/0.7l borovicka:',y:2:2); writeln('3/0.7l citrus: ',z:2:2); writeln('-------------------'); writeln('chces si nieco kupit? -> stlac a'); l:=readkey; if l='a' then begin writeln('co?'); readln(c); if c=1 then begin writeln('zaplatit ',x:2:2); cena:=cena+x; end else if c=2 then begin clrscr; writeln('zaplatit ',y:2:2); cena:=cena+y; end else if c=3 then begin clrscr; writeln('zaplatit ',z:2:2); cena:=cena+z; end else if (c=12)or(c=21) then begin clrscr; writeln('zaplatit ',(x+y):2:2); cena:=cena+y+x; end else if (c=13) or (c=31) then begin clrscr; writeln('zaplatit ',(x+z):2:2); cena:=cena+x+z; end else if (c=23) or (c=32) then begin clrscr; writeln('zaplatit ',(y+z):2:2); cena:=cena+y+z; end else if (c=123) or (c=132) or (c=213) or (c=231) or (c=312) or (c=321) then begin clrscr; writeln('zaplatit ',(x+y+z):2:2); cena:=cena+y+x+z; end else writeln('zla volba'); writeln('********'); end; end; if (m<=cena) then begin clrscr; writeln('nedostatok penazi'); end else begin writeln('priebezna cena nakupov: ' ,cena:2:2); writeln; end; until (o='n')or(m<=cena); end; {potraviny} if p='3' then begin clrscr; repeat writeln('sukromne potraviny:'); writeln('-------------------'); writeln('vyber si oddelenie'); writeln('p / pecivo'); writeln('m / mliecne'); writeln('a / alkohol'); writeln('n / naspat'); o:=readkey; if (o<>'p')and(p<>'m')and(p<>'a')and(p<>'n') then begin clrscr; end; if o='p' then begin x:=31.50; y:=2.90; z:=4.00; clrscr; writeln('Oddelenie peciva'); writeln('----------------'); writeln('1/chleba: ',x:2:2); writeln('2/rozok: ',y:2:2); writeln('3/praclik: ',z:2:2); writeln('---------------'); writeln('chces si nieco kupit? -> stlac a'); l:=readkey; if l='a' then begin writeln('co?'); readln(c); if c=1 then begin writeln('zaplatit ',x:2:2); cena:=cena+x; end else if c=2 then begin clrscr; writeln('zaplatit ',y:2:2); cena:=cena+y; end else if c=3 then begin clrscr; writeln('zaplatit ',z:2:2); cena:=cena+z; end else if (c=12)or(c=21) then begin clrscr; writeln('zaplatit ',(x+y):2:2); cena:=cena+y+x; end else if (c=13) or (c=31) then begin clrscr; writeln('zaplatit ',(x+z):2:2); cena:=cena+x+z; end else if (c=23) or (c=32) then begin clrscr; writeln('zaplatit ',(y+z):2:2); cena:=cena+y+z; end else if (c=123) or (c=132) or (c=213) or (c=231) or (c=312) or (c=321) then begin clrscr; writeln('zaplatit ',(x+y+z):2:2); cena:=cena+y+x+z; end else writeln('zla volba'); writeln('**************'); end; end; if o='m' then begin x:=21.00; y:=35.00; z:=11.90; clrscr; writeln('Oddelenie mliecnych'); writeln('-------------------'); writeln('1/mlieko: ',x:2:2); writeln('2/syry: ',y:2:2); writeln('3/smotana:',z:2:2); writeln('---------------'); writeln('chces si nieco kupit? -> stlac a'); l:=readkey; if l='a' then begin writeln('co?'); readln(c); if c=1 then begin writeln('zaplatit ',x:2:2); cena:=cena+x; end else if c=2 then begin clrscr; writeln('zaplatit ',y:2:2); cena:=cena+y; end else if c=3 then begin clrscr; writeln('zaplatit ',z:2:2); cena:=cena+z; end else if (c=12)or(c=21) then begin clrscr; writeln('zaplatit ',(x+y):2:2); cena:=cena+y+x; end else if (c=13) or (c=31) then begin clrscr; writeln('zaplatit ',(x+z):2:2); cena:=cena+x+z; end else if (c=23) or (c=32) then begin clrscr; writeln('zaplatit ',(y+z):2:2); cena:=cena+y+z; end else if (c=123) or (c=132) or (c=213) or (c=231) or (c=312) or (c=321) then begin clrscr; writeln('zaplatit ',(x+y+z):2:2); cena:=cena+y+x+z; end else writeln('zla volba'); writeln('**************'); end; end; if o='a' then begin x:=115.00; y:=145.50; z:=225.00; clrscr; writeln('Oddelenie alkoholickych napojov'); writeln('-------------------------------'); writeln('1/0.5l vodka: ',x:2:2); writeln('2/0.7l borovicka:',y:2:2); writeln('3/0.7l citrus: ',z:2:2); writeln('-------------------'); writeln('chces si nieco kupit? -> stlac a'); l:=readkey; if l='a' then begin writeln('co?'); readln(c); if c=1 then begin writeln('zaplatit ',x:2:2); cena:=cena+x; end else if c=2 then begin clrscr; writeln('zaplatit ',y:2:2); cena:=cena+y; end else if c=3 then begin clrscr; writeln('zaplatit ',z:2:2); cena:=cena+z; end else if (c=12)or(c=21) then begin clrscr; writeln('zaplatit ',(x+y):2:2); cena:=cena+y+x; end else if (c=13) or (c=31) then begin clrscr; writeln('zaplatit ',(x+z):2:2); cena:=cena+x+z; end else if (c=23) or (c=32) then begin clrscr; writeln('zaplatit ',(y+z):2:2); cena:=cena+y+z; end else if (c=123) or (c=132) or (c=213) or (c=231) or (c=312) or (c=321) then begin clrscr; writeln('zaplatit ',(x+y+z):2:2); cena:=cena+y+x+z; end else writeln('zla volba'); writeln('********'); end; end; if (m<=cena) then begin clrscr; writeln('nedostatok penazi'); end else begin writeln('priebezna cena nakupov: ' ,cena:2:2); writeln; end; until (o='n')or(m<=cena); end; if p='4' then writeln('celkova cena nakupov: ' ,cena:2:2); until (p='4')or(m<=cena); if m>=cena then writeln('dobry nakup'); readln; end.