Make your own free website on Tripod.com

program student_file;
uses wincrt;
var
number, num, j, sum : integer;
name : array[1..50] of string;
classnumber : array[1..50] of integer;
sex : array[1..50] of char;
procedure student_number;
begin
repeat
write('How many students do your class have (1 - 50) ?');
readln(number);
if (number<1) or (number>50)
then writeln('Wrong number!');
until (number>=1) and (number<=50)
end;
procedure class_sex;
begin
for j := 1 to number do
begin
write('Name of the student ',j,'?');
readln(name[j]);
repeat
write('Class number of ',name[j],' (1-50)?');
readln(classnumber[j]);
if (classnumber[j] > 50) or (classnumber[j] <= 0)
then writeln('Impossible, reenter please!');
until (classnumber[j] <= 50) and (classnumber[j] > 0);
repeat
write('Sex (M/F)?');
readln(sex[j]);
if (sex[j] <> 'M') and (sex[j] <> 'F') and (sex[j] <> 'm') and (sex[j]<> 'f')
then writeln('What do you mean? Reenter please!');
until (sex[j] = 'M') or (sex[j] = 'F') or (sex[j] = 'm') or (sex[j] = 'f');
if sex[j] = 'm' then sex[j] := 'M';
if sex[j] = 'f' then sex[j] := 'F'
end;
end;
procedure search;
var
search_name : string;
search_num, choice : integer;
begin
sum := 0;
repeat
writeln('What type of search do you want :');
writeln(' 1. Name');
writeln(' 2. Class No.');
writeln(' 3. Quit');
write('Search for 1, 2 or 3 ? ');
readln(choice);
if choice = 1
then
begin
write('What is the Name? ');
readln(search_name);
for j := 1 to number do
if name[j] = search_name
then
begin
writeln('Name = ',name[j]);
writeln('Class No. = ',classnumber[j]);
writeln('Sex = ',sex[j]);
sum := 1;
end;
if sum <> 1
then writeln('Sorry, no such student! Enter again!');
sum := 0;
end
else if choice = 2
then
begin
write('What is the Class No.? ');
readln(search_num);
for j := 1 to number do
if classnumber[j] = search_num
then
begin
writeln('Name = ',name[j]);
writeln('Class No. = ',classnumber[j]);
writeln('Sex = ',sex[j]);
sum := 1;
end;
if sum = 0
then writeln('Sorry no such student!');
sum := 0;
end
else if choice = 3
then writeln('Bye bye!')
else writeln('Sorry, no such choice! Enter again!');
until choice = 3;
end; 
begin {Main Program}
student_number;
class_sex;
search
end.