program shop; uses crt; var nr1,nr2,tax1,main1:integer; tax2,tax3,prod1,prod2,prod3,prod4,prod5,dis1,dis3,sum, sum1,sum2,sum3,sum4,sum5,ship1,p1,p2,p3,p4,p5:real; e1:char; procedure continue; {cosmetics} begin writeln; writeln('<-- To Continue Press Enter'); readln; end; {continue} procedure tax; {this procedure defines the value of tax2 used to display and calculate prices with or without taxes} begin clrscr; writeln; writeln('Are you?'); writeln; writeln('1. A Business?'); writeln('2. An Individual?'); writeln; readln(tax1); case tax1 of 1: tax2:=0.75; 2: tax2:=1.00; end; { case } end; {tax} procedure products; {this is kept sperate in order to aid price or tax-changes, it is supposed to be read from a file} begin prod1:=1595; prod2:=2695; prod3:=189; prod4:=795; prod5:=4495; prod1:=prod1*tax2; prod2:=prod2*tax2; prod3:=prod3*tax2; prod4:=prod4*tax2; prod5:=prod5*tax2; end; {products} procedure busidis1; {used to calculate buisiness discounts} begin dis1:=1; if p1>3 then dis1:=0.95; if p2>3 then dis1:=0.95; if p3>3 then dis1:=0.95; if p4>3 then dis1:=0.95; if p5>3 then dis1:=0.95; if p1>10 then dis1:=0.90; if p2>10 then dis1:=0.90; if p3>10 then dis1:=0.90; if p4>10 then dis1:=0.90; if p5>10 then dis1:=0.90; if p1>25 then dis1:=0.85; if p2>25 then dis1:=0.85; if p3>25 then dis1:=0.85; if p4>25 then dis1:=0.85; if p5>25 then dis1:=0.85; end; {busidis1} procedure privdis1; {used to calculate private discounts} begin dis1:=1; if p1>3 then dis1:=0.95; if p2>3 then dis1:=0.95; if p3>3 then dis1:=0.95; if p4>3 then dis1:=0.95; if p5>3 then dis1:=0.95; if sum>9999.99 then dis1:=0.90; end; {privdis1} procedure shipping; {is used to calculate shipping-fees} begin ship1:=40; if sum>5000 then ship1:=0; if sum<1 then ship1:=0; ship1:=ship1*(p1+p2+p3+p4+p5); if p1>4 then ship1:=0; if p2>4 then ship1:=0; if p3>4 then ship1:=0; if p4>4 then ship1:=0; if p5>4 then ship1:=0; end; {shipping} procedure discount; {tax-level chooser} begin if tax2=1.00 then privdis1; if tax2=0.75 then busidis1; end; {discount} procedure count; begin clrscr; products; sum1:=p1*prod1; sum2:=p2*prod2; sum3:=p3*prod3; sum4:=p4*prod4; sum5:=p5*prod5; sum:=sum1+sum2+sum3+sum4+sum5; begin shipping; sum:=sum+ship1; discount; sum:=sum*dis1; dis3:=dis1*100; tax3:=tax2*100; end; writeln('Current Order is: '); writeln; writeln('+----+----------------------+-------+------------------------'); writeln('| # | Name: | MB: | Nr: Price(SEK):'); writeln('+----+----------------------+-------+------------------------'); writeln('| 1. | Techno Star | 32MB | ',p1:0:0,' @ ',prod1:0:2,' = ',sum1:0:2,''); writeln('| 2. | Techno Star | 64MB | ',p2:0:0,' @ ',prod2:0:2,' = ',sum2:0:2,''); writeln('| 3. | Simple Lowcost | 4MB | ',p3:0:0,' @ ',prod3:0:2,' = ',sum3:0:2,''); writeln('| 4. | Ultra Flex | 16MB | ',p4:0:0,' @ ',prod4:0:2,' = ',sum4:0:2,''); writeln('| 5. | Creation Megablaster | 128MB | ',p5:0:0,' @ ',prod5:0:2,' = ',sum5:0:2,''); writeln('+----+----------------------+-------+------------------------'); writeln; writeln('Note!'); writeln('These are included in total price:'); writeln('Shipping fee:.......... ',ship1:0:2,' SEK '); writeln('Discount percentage:... ',dis3:0:0,' % '); writeln('Taxlevel............... ',tax3:0:0,' % '); writeln; writeln; writeln(' Total sum: ',sum:0:2,' SEK '); writeln; writeln; continue; end; {count} procedure spinin; begin clrscr; writeln('+----+----------------------+-------+------------'); writeln('| # | Name: | MB: | Nr: '); writeln('+----+----------------------+-------+------------'); writeln('| 1. | Techno Star | 32MB | ',p1:0:0,' '); writeln('| 2. | Techno Star | 64MB | ',p2:0:0,' '); writeln('| 3. | Simple Lowcost | 4MB | ',p3:0:0,' '); writeln('| 4. | Ultra Flex | 16MB | ',p4:0:0,' '); writeln('| 5. | Creation Megablaster | 128MB | ',p5:0:0,' '); writeln('+----+----------------------+-------+------------'); writeln; writeln('(When done simply select "0" to quit)'); writeln; write('select product: '); readln(nr1); if nr1>0 then begin writeln; write('how many?: '); readln(nr2); case nr1 of 1: p1:=p1+(nr2); 2: p2:=p2+(nr2); 3: p3:=p3+(nr2); 4: p4:=p4+(nr2); 5: p5:=p5+(nr2); end; { case } spinin; end else count; end; procedure erase; begin clrscr; writeln; writeln('This will erase your shopping-cart!'); writeln('are you sure? y/n'); readln(e1); if e1='y' then begin p1:=0; p2:=0; p3:=0; p4:=0; p5:=0; end; end; procedure order; var myfile : text; filename,name,street,city,mail,postnr,telephone,cell : string; begin clrscr; count; clrscr; writeln; write('Enter name (ex. Daniel Davis): '); readln(name); write('Street-address(ex. smith street 43): '); readln(street); write('Postal nr(ex. 431 50): '); readln(postnr); write('City (ex. Gothenburg): '); readln(city); write('Telephone nr.(Optional): '); readln(telephone); write('Cellular Phone(Optional): '); readln(cell); write('E-Mail(Optional): '); readln(mail); filename:='order-'+name+'.txt'; assign(myfile, filename); rewrite(myfile); writeln(myfile, name); writeln(myfile, street); writeln(myfile, postnr); writeln(myfile, city); writeln(myfile); writeln(myfile, telephone); writeln(myfile, cell); writeln(myfile); writeln(myfile, mail); writeln(myfile); writeln(myfile); writeln(myfile, '+----+----------------------+-------+------------------------'); writeln(myfile, '| # | Name: | MB: | Nr: Price(SEK):'); writeln(myfile, '+----+----------------------+-------+-------------------------'); writeln(myfile, '| 1. | Techno Star | 32MB | ',p1:0:0,' @ ',prod1:0:2,' = ',sum1:0:2,''); writeln(myfile, '| 2. | Techno Star | 64MB | ',p2:0:0,' @ ',prod2:0:2,' = ',sum2:0:2,''); writeln(myfile, '| 3. | Simple Lowcost | 4MB | ',p3:0:0,' @ ',prod3:0:2,' = ',sum3:0:2,''); writeln(myfile, '| 4. | Ultra Flex | 16MB | ',p4:0:0,' @ ',prod4:0:2,' = ',sum4:0:2,''); writeln(myfile, '| 5. | Creation Megablaster | 128MB | ',p5:0:0,' @ ',prod5:0:2,' = ',sum5:0:2,''); writeln(myfile, '+----+----------------------+-------+------------------------'); writeln(myfile); writeln(myfile, 'Note!'); writeln(myfile, 'These are included in total price:'); writeln(myfile, 'Shipping fee:.......... ',ship1:0:2,' SEK '); writeln(myfile, 'Discount percentage:... ',dis3:0:0,' % '); writeln(myfile, 'Taxlevel............... ',tax3:0:0,' % '); writeln(myfile); writeln(myfile); writeln(myfile, ' Total sum: ',sum:0:2,' SEK '); writeln(myfile); close(myfile); writeln('Thanks for your Business :-)'); delay(1500); end; procedure offers; {text-document} var myfile : text; filename, printit : string; begin clrscr; filename:='ship.txt'; assign(myfile, filename); reset(myfile); repeat readln(myfile, printit); writeln(printit); until eof(myfile); continue; close(myfile); end; {offers} procedure mainmenu; {"home" sort of} begin clrscr; writeln; writeln(' 1. Buy Products '); writeln(' 2. View Shopping-Cart '); writeln(' 3. Erase Shopping-Cart '); {erase all arrays} writeln(' 4. Shipping/Taxes '); writeln(' 5. choose taxlevel '); writeln(' 6. Order '); {write to file?} writeln(' 7. Exit '); writeln; writeln('(Use Numbers 1-7 then press enter)'); writeln; readln(main1); case main1 of 1: spinin; 2: count; 3: erase; 4: offers; 5: tax; 6: order; end; { case } end; {mainmenu} begin tax2:=1.00; p1:=0; p2:=0; p3:=0; p4:=0; p5:=0; products; repeat mainmenu; until main1=7; end.