WWW.VIRTUALeMEDIA.COM

CONTACT US  |  HOMEPAGE

VIRTUALeMEDIA                   SOFTWARE ENGINEERING
CLOTHING  ::  ELECTRONICS  ::  HARDWARE  ::  GIFTS  ::  BOOKS  ::  FINANCE  ::  SOFTWARE  ::  EMPLOYMENT ::   VIRTUAL OFFICES
COOL STUFF

AUDIO

COMPUTERS

NETWORKS

PDAs

SUPPLIES

TELEVISIONS

WIRELESS

TECHNOLOGY

ARTICLES

HARDWARE

SOFTWARE

PROGRAMMING

WEBMARKETING

WIRELESS


LINKS

 
 

FREELANCING

VIRTUALeOFFICES

TRADELINKS

 

GEMINISOFTWARE

 

 

 

 

 

 

 

Allume Systems Software     Record Streaming Video. CLICK HERE!          SnapDialer: use cellphone to connect PC to the web     GEAR CD/DVD Burning Software     

_________________________________________________________________________________________

LearnKey Training

___________________

 

Welcome to our website

 

{$U+}

program students(input,output);


const max = 100;
blank = ' ';

type

person = record
num : array[1..max] of integer;
firstname : array[1..max,1..10] of char;
lastname : array[1..max,1..10] of char;
gpa : array[1..max] of real;
major : array[1..max,1..5] of char;
end;

var
student : person;
infile : text;
flag : boolean;
stoprint : integer;


{********************************************************************}

{ This procedure gets the first name of the student w/the highest GPA.
}

procedure getstdnt1(var stdnt : person; linenum : integer);

var
i : integer;
chname,chgpa : char;

begin
write(' ':22); { Space the name over. }
i := 1;
chname := student.firstname[linenum,i];
while chname <> blank do
begin
write(student.firstname[linenum,i]);
i := i + 1;
chname := student.firstname[linenum,i]
end;
write(blank)
end;

{********************************************************************}

{ This procedure gets the last name of the student w/the highest GPA.
}

procedure getstdnt2(var stdnt : person; linenum : integer);

var
i : integer;
ch : char;

begin
i := 1;
ch := student.lastname[linenum,i];
while ch <> blank do
begin
write(student.lastname[linenum,i]);
i := i + 1;
ch := student.lastname[linenum,i]
end;
write(blank)
end;


{********************************************************************}

procedure getstdntmaj(var stdnt : person; linenum : integer);

var
i : integer;
ch : char;

begin
write(' ':9); { Make spaces between major & GPA. }
i := 1;
ch := student.major[linenum,i];
while ch <> blank do
begin
write(student.major[linenum,i]);
i := i + 1;
ch := student.major[linenum,i]
end
end;

{********************************************************************}

{ This procedure gets the highest GPA from the list.
}

procedure gethighest(var student : person; quithigh : integer);

var
temp,grade : real;
locale,i : integer;


begin
temp := 0.00;
for i := 1 to quithigh do
begin
grade := student.gpa[i];
if grade > temp then
begin
temp := grade;
locale :=i
end
end;
writeln;
getstdnt1(student,locale);
getstdnt2(student,locale);
getstdntmaj(student,locale);
writeln
end;


{********************************************************************}

{ This procedure gets the average GPA from the list.
}

procedure getaverage(var student : person; quitave : integer);

var
avg,allavgs,average : real;
i : integer;

begin
allavgs := 0.00;
for i := 1 to quitave do
begin
avg := student.gpa[i];
allavgs := avg + allavgs
end;
average := allavgs / 12;
writeln;
writeln('Average = ',average:1:2)
end;


{********************************************************************}

{ This procedure gets the first name for the CS major.
}

procedure getperson1(var stdnt : person; linenum : integer);

var
i : integer;
chname,chgpa : char;

begin
write(' ':32); { Space the name over. }
i := 1;
chname := student.firstname[linenum,i];
while chname <> blank do
begin
write(student.firstname[linenum,i]);
i := i + 1;
chname := student.firstname[linenum,i]
end;
write(blank)
end;



{********************************************************************}

{ This procedure get the last name for the CS major.
}

procedure getperson2(var student : person; linenum : integer);


var
i : integer;
ch : char;

begin
i := 1;
ch := student.lastname[linenum,i];
while ch <> blank do
begin
write(student.lastname[linenum,i]);
i := i + 1;
ch := student.lastname[linenum,i]
end;
write(blank)
end;


{********************************************************************}

{ This procedure gets the GPA for the CS major.
}

procedure gethegpa(var student : person; linenum : integer);


begin
write(student.gpa[linenum]:3:2);
write(blank)
end;

{********************************************************************}

{ This procedure looks for CS majors and sends them to "getperson
{ for printing.
}

procedure csearch(var student : person; pos : integer);

var
i,j : integer;
temp : char;


begin
i := 1;
temp := student.major[pos,i];
if temp = 'C' then
i := i + 1;
temp := student.major[pos,i];
if temp = 'S' then
begin
getperson1(student,pos);
getperson2(student,pos);
gethegpa(student,pos)
end;
end;

{********************************************************************}

{ This procedure is the driver for the CS section of the program.
}
procedure csfind(var stdnt : person; quitsearch : integer);

var i : integer;

begin
for i:= 1 to quitsearch do
begin
writeln;
csearch(stdnt,i)
end
end;

{********************************************************************}

procedure printnum(var outfile : text; var student : person;
linenum : integer);


begin
write(outfile,student.num[linenum]:9)
end;


{********************************************************************}

procedure printnam1(var outfile : text; var student : person;
var numpad : integer;
linenum : integer);



var
i : integer;
ch : char;

begin
write(' ':18);
i := 1;
ch := student.firstname[linenum,i];
while ch <> blank do
begin
write(outfile,student.firstname[linenum,i]);
i := i + 1;
ch := student.firstname[linenum,i]
end;
numpad := i + 1;
write(outfile,blank)
end;



{********************************************************************}

procedure printnam2(var outfile : text; var student : person;
numpad,linenum : integer);

const distance = 25;


var
pad,i : integer;
ch : char;

begin
i := 1;
ch := student.lastname[linenum,i];
while ch <> blank do
begin
write(outfile,student.lastname[linenum,i]);
i := i + 1;
ch := student.lastname[linenum,i]
end;
numpad := numpad + i;
numpad := distance - numpad;
for pad := 1 to numpad do
write(outfile,blank)
end;



{********************************************************************}

procedure printgpa(var outfile : text; var student : person;
linenum : integer);


begin
write(outfile,student.gpa[linenum]:4:2);
write(blank)
end;


{********************************************************************}

procedure printmaj(var outfile : text; var student : person;
linenum : integer);


var
i : integer;
ch : char;

begin
write(' ':6); { Make spaces between major & GPA. }
i := 1;
ch := student.major[linenum,i];
while ch <> blank do
begin
write(outfile,student.major[linenum,i]);
i := i + 1;
ch := student.major[linenum,i]
end
end;


{********************************************************************}

procedure printstdnts( var otfil : text; var stdnt : person;
quitprint : integer);

var
numblanks,i : integer;

begin
for i := 1 to quitprint do
begin
numblanks := 0;
printnum(otfil,stdnt,i);
printnam1(otfil,stdnt,numblanks,i);
printnam2(otfil,stdnt,numblanks,i);
printgpa(otfil,stdnt,i);
printmaj(otfil,stdnt,i);
writeln(otfil)
end
end;


{********************************************************************}

{ This procedure is the driver for the print section of the program.
}

procedure printlist(var student : person; var stoprint : integer);

{--------------------------------------------------------------------}

{ This procedure prints the labels at the top of the student list.
}

procedure header(var otfil : text);

begin { Header }
write(otfil,'STUDENT NUMBER':14);
write(otfil,'NAME':20);
write(otfil,'GPA':19);
writeln(otfil,'MAJOR':12);
write(otfil,'------- ------':14);
write(otfil,'----':20);
write(otfil,'---':19);
writeln(otfil,'-----':12)
end; { Header }

{--------------------------------------------------------------------}


var
outfile :text;

begin { Printlist }
assign(outfile,'CON'); { Get ready to write to the printer. }
{$i-}
rewrite(outfile);
{$i+}
header(outfile);
printstdnts(outfile,student,stoprint)
end; { Printlist }


{********************************************************************}

{ This procedure reads past the blanks that follow the reading
{ of a number.
}

procedure skipblank(var infile : text);

var ch : char;

{ This procedure moves the file pointer past the blank. }

begin
read(infile,ch);
write(ch)
end;


{********************************************************************}

{ This procedure reads,stores and echoprints a student number from the
{ datafile on the disk.
}

procedure getnum(var infile : text; var student : person;
linenum : integer);



begin
read(infile,student.num[linenum]);
write(student.num[linenum])
end;


{********************************************************************}

{ This procedure reads in a first name and stops when a blank is
{ encountered.
}

procedure getname1(var infile : text; var student : person;
linenum : integer);



var
i : integer;
ch : char;

begin
i := 1;
read(infile,student.firstname[linenum,i]);
ch := student.firstname[linenum,i];
while ch <> blank do
begin
write(student.firstname[linenum,i]);
i := i + 1;
read(infile,student.firstname[linenum,i]);
ch := student.firstname[linenum,i];
end;
write(blank)
end;


{********************************************************************}

{ This procedure reads in a last name and stops when a blank is
{ encountered.
}

procedure getname2(var infile : text; var student : person;
linenum : integer);



var
i : integer;
ch : char;

begin
i := 1;
read(infile,student.lastname[linenum,i]);
ch := student.lastname[linenum,i];
while ch <> blank do
begin
write(student.lastname[linenum,i]);
i := i + 1;
read(infile,student.lastname[linenum,i]);
ch := student.lastname[linenum,i];
end;
write(blank)
end;


{********************************************************************}

{ This procedure reads the integer: GPA, from the disk, stores it in
{ an array and echoprints it.
}

procedure getgpa(var infile : text; var student : person;
linenum : integer);


begin
read(infile,student.gpa[linenum]);
write(student.gpa[linenum]:2:2);
write(blank)
end;


{********************************************************************}

{ This procedure reads a student major from the disk, stores it in an
{ array and echoprints it to the screen.
}

procedure getmajor(var infile : text; var student : person;
linenum : integer);


var
i : integer;
ch : char;

begin
i := 1;
read(infile,student.major[linenum,i]);
ch := student.major[linenum,i];
while ch <> blank do
begin
write(student.major[linenum,i]);
i := i + 1;
read(infile,student.major[linenum,i]);
ch := student.major[linenum,i]
end
end;


{********************************************************************}

{ This procedure checks for end of line. }

procedure chekendln(var infile : text; var flag : boolean);

const mark = '|';

var
ch : char;


begin
read(infile,ch);
while ch <> mark do
begin
read(infile,ch);
if ch = mark then
flag := true
end
end;


{********************************************************************}

{ This procedure checks for end of file. }

procedure chekeof(var infile : text; var flag : boolean);

const mark = '*';

var
ch : char;


begin
read(infile,ch);
if ch = mark then
flag := true
end;




{********************************************************************}

{ This procedure drives the set of procedures that read, echoprint
{ and store the individual columns from the list of students on the
{ disk file.
}

procedure getlist(var infl : text; var studnt : person;
var pos : integer);


begin { Getlist }
pos := pos + 1;
getnum(infl,studnt,pos); { Student number. }
skipblank(infl);
getname1(infl,studnt,pos); { First name. }
getname2(infl,studnt,pos); { Last name. }
getgpa(infl,studnt,pos); { GPA. }
skipblank(infl); { Major. }
getmajor(infl,studnt,pos);
end; { Getlist }

{********************************************************************}

{ This procedure is the driver for the reading and echo printing
{ of the data file, lab1.dat".
}

procedure reedfil(var nfil : text; var stdnt : person;
var stoprint : integer);

var
i : integer;
flageof,flagln : boolean;


begin
{$i-}
reset(nfil);
{$i+}
clrscr;
i := 0; { Set the line counter to zero. }
flageof := false;
while not flageof do { While not EOF }
begin
flagln := false;
while not flagln do { While not EOLN }
begin
getlist(nfil,stdnt,i); { Gets the list of students. }
chekendln(nfil,flagln) { Look for EOLN }
end; { while not EOLN }
chekeof(nfil,flageof); { Look for EOF }
readln(nfil);
writeln;
end; { While not EOF }
stoprint := i; { Tells when to stop printing the record }
writeln { so "printlist can stop correctly. }
end;


{********************************************************************}

{ This procedure keeps the program from "running away" and returning
{ to the main menu.
}

procedure scrnhold;

var i : integer;

begin
writeln;
writeln('Press enter to continue . .');
readln { Cannot continue until return pressed. }
end;

{********************************************************************}

{ This procedure allows the user to choose the part of the program
{ that he wishes to use.
}

procedure select(var nfl : text; var studnt : person;
var quitjob : integer;
var gate : boolean);

var ch : char;


begin
read(ch);
ch := upcase(ch);
case ch of
'A' : begin { Read and echoprint datafile. }
clrscr; { *This option MUST be chosen first.* }
reedfil(nfl,studnt,quitjob);
scrnhold
end;
'B' : begin { Write to a file and print formatted. }
clrscr;
printlist(studnt,quitjob);
scrnhold
end;
'C' : begin { Find the CS majors and print }
clrscr; { their names and GPA`s }
writeln('CS majors':42);
writeln('---------':42);
csfind(studnt,quitjob);
scrnhold
end;
'D' : begin { Calculate and print the average GPA. }
clrscr;
writeln('Average GPA':42);
writeln('-----------':42);
getaverage(studnt,quitjob);
scrnhold
end;
'E' : begin { Find the student with the highest GPA }
clrscr; { and print their name }
writeln('Highest GPA':42);{ and major. }
writeln('-----------':42);
gethighest(studnt,quitjob);
scrnhold
end;
'X' : begin { Leave program. }
clrscr;
writeln('Exit.');
gate := true
end
end; { CASE }
end; { Select }


{********************************************************************}

procedure menu;

var
i,j : integer;


begin
clrscr;
writeln(' Lab1.pas');
writeln;
writeln;
writeln('----------------------':47);
writeln('| RECORDS |':47);
writeln('----------------------':47);
writeln;
writeln;
writeln('A: READ AND ECHOPRINT ':47);
writeln;
writeln('B: PRINT LIST':38);
writeln;
writeln('C: PRINT CS MAJORS':43);
writeln;
writeln('D: PRINT AVERAGE GPA':45);
writeln;
writeln('E: PRINT HIGHEST GPA':45);
writeln;
writeln('X: EXIT':32);
for i := 1 to 3 do
writeln;
write('Choose an option . .');
writeln;
end; { Menu }


{********************************************************************}

begin
assign(infile,'lab1.dat');
flag := false;
stoprint :=0;
while not flag do { X:EXIT not selected. }
begin
menu; { Display menu. }
select(infile,student,stoprint,flag) { Menu options. }
end;
close(infile)
end.

 

DATAFILE: LAB1.DAT

1235 Sam Smith 2.75 CS |
3251 Mary Blake 3.32 MA |
8724 Bob Williams 1.99 BYS |
7765 Christine White 3.45 CS |
2395 Richard Smith 3.87 PY |
1818 Debbie Blake 3.1 CS |
4905 Dick Brown 2.75 CH |
3875 Sue Jones 2.50 CS |
7788 Chris Christen 2.15 MA |
2947 Mike Smith 3.16 CH |
2325 Lane Mosley 3.25 PY |
4128 Missy Valves 2.78 BYS |*

_________________________________________________________________________________________

 

 

 

 

 

 

About Us

Content provided by VirtualeCorporation

 
 

 

 

Google

GeminiSoftwareSystems     GeminiMalls     GeminiMagazine     TradeLinks

VirtualeCatalog     VirtualeCorporation     VirtualeDirectory     VirtualeJobs     VirtualeMedia     VirtualeOffices

_______________________________________________________________________________________

Give to Charities Click Here!

Michael J. Fox Parkinson's Website Click Here!

__________________________________________

Software including hosting, websites, graphics, development, office, security..Click Here!

 

________________________________________________________________________________________

Save up to 75% on software     CoffeeCup Software     GoToMyPC - Access Your PC From Anywhere     Students software at 50% off!     Get New Emoticons     www.ITCFonts.com

 

Buy Online at Autodesk

"Internet Security Systems' BlackICE Protection Products"

 Need to create a business plan now? Get OfficeReady Business Plans

 Kaspersky Anti-Virus Products

 Free Shipping when you spend $100 on Macromedia.com

 Convert paper and PDF into Documents you can edit, share and archive - Buy OmniPage Pro from ScanSoft.

 Broderbund Bargain Bin - All Titles Under $9.99! Plus FREE shipping with orders over $20!

GameFly® Video Game Rentals - Free Trial          Free Stuff     Aces High 88 Button          

_____________________

Simpson's Monopoly

 

 

 

Google

 

 

 

 

© COPYRIGHT 2002 ALL RIGHTS RESERVED YOURDOMAIN.COM

CLOTHING  ::  ELECTRONICS  ::  HARDWARE  ::  GIFTS  ::  BOOKS  ::  FINANCE  ::  SOFTWARE  ::  EMPLOYMENT     VIRTUAL OFFICES