ArmandVanShader

Курсовая работа 15 вариант

May 13th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 5.43 KB | None | 0 0
  1. uses crt;
  2. type abbit=record
  3.     surname,country:string[15];
  4.     math,phys,russ:byte;
  5.     sex,entrant:boolean;
  6. end;
  7.  
  8. var i,vybor,counter,found:integer;
  9.     baza:file of abbit;
  10.     rec:abbit;
  11.  
  12. const punkty:array[1..6] of string=('1) Create baza','2) Add new records',
  13.     '3) Show all records','4) Total scores','5) Statistics','6) Exit');
  14.     minimum=150;
  15.  
  16. procedure zastavka;
  17. begin
  18. clrscr;
  19. gotoxy(36,12);
  20. write('Cource work');
  21. gotoxy(32,14);
  22. write('Medvedeva Anastasia');
  23. readkey;
  24. end;
  25.  
  26.  
  27. procedure menu(var punkt:integer);
  28. var i:integer;
  29. begin clrscr;
  30. for i:=1 to 6 do begin
  31.     writeln(punkty[i]);
  32.     end;
  33. writeln;
  34. write('Enter number: ');
  35. readln(punkt);
  36. end;
  37.  
  38. procedure sozdanie;
  39. var temp:string[1];
  40. begin
  41. clrscr;
  42. writeln('Enter data for abbiturient №1:');
  43. with rec do begin
  44. write('Surname:');readln(surname);
  45. write('Math grade:');readln(math);
  46. write('Physics grade:');readln(phys);
  47. write('Russian language grade:');readln(russ);
  48. repeat
  49.     write('Sex (m=male,f=female):');readln(temp);
  50.     if temp='f' then
  51.         sex:=false
  52.     else
  53.         if temp='m' then
  54.             sex:=true
  55.         else begin
  56.             textcolor(lightred);
  57.             gotoxy(23,wherey-1);
  58.             write('   Error: value is incorrect! Repeat entry.');
  59.             textcolor(7);
  60.             gotoxy(1,wherey)
  61.             end;
  62. until (temp='f') or (temp='m');
  63.  
  64. repeat
  65.     write('Out-of-town: (y=true,n=false):');readln(temp);
  66.     if temp='n' then
  67.         entrant:=false
  68.     else
  69.         if temp='y' then
  70.             entrant:=true
  71.         else begin
  72.             textcolor(lightred);
  73.             gotoxy(31,wherey-1);
  74.             write('   Error: value is incorrect! Repeat entry.');
  75.             textcolor(7);
  76.             gotoxy(1,wherey)
  77.             end;
  78. until (temp='y') or (temp='n');
  79. write('Country:');readln(country);
  80. end;
  81.  
  82. rewrite(baza);
  83. write(baza,rec);
  84. close(baza);
  85. writeln;
  86. write('Database is successfully created and the first record is added.');
  87. readkey;
  88. end;
  89.  
  90.  
  91. procedure dobavlenie;
  92. var escape,temp:char;
  93. begin
  94. reset(baza);
  95. counter:=Filesize(baza);
  96. Seek(baza, counter);
  97. repeat
  98.     clrscr;
  99.     writeln('Enter data for abbiturient №',counter+1,':');
  100.     with rec do begin
  101.     write('Surname:');readln(surname);
  102.     write('Math grade:');readln(math);
  103.     write('Physics grade:');readln(phys);
  104.     write('Russian language grade:');readln(russ);
  105.     repeat
  106.         write('Sex (m=male,f=female):');readln(temp);
  107.         if temp='f' then
  108.             sex:=false
  109.         else
  110.             if temp='m' then
  111.             sex:=true
  112.         else begin
  113.             textcolor(lightred);
  114.             gotoxy(23,wherey-1);
  115.             write('   Error: value is incorrect! Repeat entry.');
  116.             textcolor(7);
  117.             gotoxy(1,wherey)
  118.             end;
  119. until (temp='f') or (temp='m');
  120.  
  121. repeat
  122.     write('Out-of-town: (y=true,n=false):');readln(temp);
  123.     if temp='n' then
  124.         entrant:=false
  125.     else
  126.         if temp='y' then
  127.             entrant:=true
  128.         else begin
  129.             textcolor(lightred);
  130.             gotoxy(31,wherey-1);
  131.             write('   Error: value is incorrect! Repeat entry.');
  132.             textcolor(7);
  133.             gotoxy(1,wherey)
  134.             end;
  135. until (temp='y') or (temp='n');
  136. write('Country:');readln(country);
  137. end;
  138.  
  139. inc(counter);
  140. write(baza,rec);
  141. writeln;
  142. write(' Enter 0 to exit or any key continiue:');readln(escape);
  143. until escape='0';
  144. close(baza);
  145. end;
  146.  
  147. procedure vyvod;
  148. begin
  149. clrscr;
  150. reset(baza);
  151. writeln('Surname        Sex    Math Phys Russ City   Country');
  152. writeln('---------------------------------------------------');
  153. for i:=1 to filesize(baza) do begin
  154.     read(baza,rec);
  155.     with rec do begin
  156.         write(surname);
  157.         gotoxy(16,wherey); if sex=true then write('male') else write('female');
  158.         gotoxy(24,wherey);write(math);
  159.         gotoxy(28,wherey);write(phys);
  160.         gotoxy(33,wherey);write(russ);
  161.         gotoxy(38,wherey); if entrant=true then write('other') else write('SpB');
  162.         gotoxy(45,wherey);writeln(country);
  163.         end;
  164.     end;
  165. if filesize(baza)=0 then write('The database is empty!');
  166. readkey;
  167. end;
  168.  
  169. procedure sum;
  170. begin
  171. clrscr;
  172. reset(baza);
  173. counter:=filesize(baza);
  174. if counter=0 then begin write('Database is empty!'); readkey; exit; end;
  175. writeln('Surname        Total score');
  176. writeln('--------------------------');
  177. for i:=1 to counter do begin
  178.     read(baza,rec);
  179.     with rec do begin
  180.         write(surname);
  181.         gotoxy(16,wherey);
  182.         writeln(math+phys+russ);
  183.         end;
  184.     end;
  185. readkey;
  186. end;
  187.  
  188. procedure stats;
  189. var male,female,CIS,Russia,hostel:integer;
  190. begin
  191. clrscr;
  192. reset(baza);
  193. counter:=filesize(baza);
  194. if counter=0 then begin write('Database is empty!'); readkey; exit; end;
  195. found:=0;male:=0; female:=0; CIS:=0; Russia:=0; hostel:=0;
  196. for i:=1 to counter do begin
  197.     read(baza,rec);
  198.     with rec do
  199.         if math+phys+russ>=minimum then begin
  200.             inc(found);
  201.             if sex=true then inc(male) else inc(female);
  202.             if (country='Armenia') or (country='Azerbaijan') or (country='Belarus')
  203.                 or (country='Kazakhstan') or (country='Kyrgyzstan') or (country='Moldova')
  204.                 or (country='Russia') or (country='Tajikistan') or (country='Turkmenistan')
  205.                 or (country='Ukraine') or (country='Uzbekistan') then inc(CIS);
  206.             if country='Russia' then inc(Russia);
  207.             if entrant=true then inc(hostel);
  208.             end;
  209.     end;
  210. writeln('Total ',found,' abbiturient(s) with total score >150.');
  211. writeln(male,' abbiturient(s) are male, ', female,' are female.');
  212. writeln(CIS,' abbiturient(s) are from CIS, including ', Russia,' from Russia. ',found-CIS,' are foreigners.');
  213. writeln(hostel,' abbiturient(s) need hostel.');
  214. readkey;
  215. end;
  216.  
  217.  
  218. begin clrscr;
  219. zastavka;
  220. assign(baza,'file.dat');
  221. repeat
  222.         menu(vybor);
  223.         case vybor of
  224.         1:sozdanie;
  225.         2:dobavlenie;
  226.         3:vyvod;
  227.         4:sum;
  228.         5:stats;
  229.         0:exit;
  230.         6:exit;
  231.         end;
  232. until (vybor=0) or (vybor=6);
  233. readkey;
  234. end.
Advertisement
Add Comment
Please, Sign In to add comment