|
AUDIO
COMPUTERS
NETWORKS
PDAs
SUPPLIES
TELEVISIONS
WIRELESS
ARTICLES
HARDWARE
SOFTWARE
PROGRAMMING
WEBMARKETING
WIRELESS

FREELANCING
VIRTUALeOFFICES
TRADELINKS
GEMINISOFTWARE
|

_________________________________________________________________________________________

___________________
Welcome
to our website
{$P256,G256}
{ THIS PASCAL PROGRAM PRINTS OUT A HISTOGRAM OF A PARTICULAR CLASSROOM }
{ AVERAGE. A '*' REPRESENTS THE NUMBER OF STUDENTS RECIEVING }
{ A CERTAIN GRADE. }
program histogram(input,output,infile,outfile);
const star = '*';
var i,class_id,numgrades,studentnum,grade,numtests : integer;
ave,no_A,no_B,no_C,no_D,no_F : integer;
lastnum : boolean;
infile,outfile : text;
symbol : char;
{******************************************************************}
procedure findlettergrade(var grade,numA,numB,numC : integer;
var numD,numF :integer);
begin { PROCEDURE HISTOGRAM }
case grade of
90..100 :numA := numA + 1; { this CASE statement is used }
80..89 : numB := numB + 1; { to sum up the number of }
70..79 : numC := numC + 1; { students recieving a certain}
60..69 : numD := numD + 1; { grade as shown. }
0..59 : numF := numF + 1;
end;
end; { HISTOGRAM }
{******************************************************************}
procedure drawbars(var histfile : text;length : integer;
barchar : char);
var count : integer;
begin { PROCEDURE DRAWBARS }
for count := 1 to length do
write(histfile,barchar); { THIS WRITES OUT AN '*' FOR }
writeln(histfile); { EACH SUM OF GRADES. }
end; { DRAWBARS }
{******************************************************************}
procedure average_grades(var grades_file :text;
var tests :integer; var average : integer;
score : integer);
var sum : integer;
begin { AVERAGE GRADES }
sum := 0;
for i := 1 to tests do
begin
read(grades_file,score);
sum := sum + score
end;
readln(grades_file);
average := sum DIV tests;
end; { AVERAGE GRADES }
{*****************************************************************}
begin { MAIN }
assign(infile,'LAB6.DAT' );
reset(infile);
assign(outfile, 'PRN' );
rewrite(outfile);
while not eof(infile) do
begin
lastnum := false; { LOOP CONTROL VARIABLE }
readln(infile,symbol,class_id,numtests);
no_A := 0;
no_B := 0;
no_C := 0;
no_D := 0;
no_F := 0;
writeln(outfile);
write(outfile,' COURSE : ',class_id);
writeln(outfile,' NUMBER OF TESTS : ',numtests);
read(infile,studentnum);
while not lastnum do { CHECKS FOR END OF CLASS GRADES }
begin
average_grades(infile,numtests,ave,grade);
findlettergrade(ave,no_A,no_B,no_C,no_D,no_F);
read(infile,studentnum);
if (studentnum = -999) then
begin
readln(infile);
lastnum := true;
end
else
lastnum := false;
end;
write(outfile, 'A : ' );
drawbars(outfile,no_A,star);{ THE NUMBER OF GRADES = LENGTH }
write(outfile, 'B : ' );
drawbars(outfile,no_B,star);
write(outfile, 'C : ' );
drawbars(outfile,no_C,star);
write(outfile, 'D : ' );
drawbars(outfile,no_D,star);
write(outfile, 'F : ' );
drawbars(outfile,no_F,star);
end;
close(infile);
close(outfile);
end.
_________________________________________________________________________________________
About
Us
Content
provided by VirtualeCorporation
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!
________________________________________________________________________________________

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!
_____________________

|