|

_________________________________________________________________________________________

___________________
Welcome
to our website
{$P256,G256,B-}
{ THIS PASCAL PROGRAM IS A TWO FUNCTION CALCULATOR. TO USE THIS }
{ CALCULATOR JUST ENTER ANY +,-,*,/ TYPE CALCULATIONS. }
{ THEN HIT 'ENTER' TWICE TO RECEIVE A RESULT AND THE }
{ OPTION TO QUIT? (Y/N) . }
program calculator(input,output);
const blank = ' ';
var oprand1 : real;
outfile : text;
flag : boolean;
ch : char; { OPERATOR }
{********************************************************************}
function compute(operand1 : real; var outfile : text) : real;
var num,operand2 : real;
function skipblanks : char; { SKIPS ALL BLANKS BEFORE THE OPERATOR }
var ch : char; { AND RETURNS TO COMPUTE THE OPERATOR. }
begin { SKIPBLANKS }
read(kbd,ch);
while ch = blank do
read(kbd,ch);
skipblanks := ch { ASSIGNS SKIPBLANKS TO THE FIRST NONBLANK }
end; { SKIPBLANKS } { CHARACTER.}
begin { FUNCTION COMPUTE }
case skipblanks of { THIS CASE REVIEVES THE FIRST NONBLANK }
'+' : begin { CHARACTER AND ASSIGNS IT TO THE CORRECT }
write(outfile,operand1:1:1); { ASSIGNMENT STATEMENT.}
readln(kbd,operand2);
writeln(outfile,' + ',operand2:3:1);
num := operand1 + operand2;
end;
'-' : begin
write(outfile,operand1:1:1);
readln(kbd,operand2);
writeln(outfile,' - ',operand2:3:1);
num := operand1 - operand2;
end;
'*' : begin
write(outfile,operand1:1:1);
readln(kbd,operand2);
writeln(outfile,' * ',operand2:3:1);
num := operand1 * operand2;
end;
'/' : begin
write(outfile,operand1:1:1);
readln(kbd,operand2);
writeln(outfile,' / ',operand2:3:1);
num := operand1 / operand2;
end;
end;
write(outfile,' RESULT : ' );
compute := num
end; { FUNCTION COMPUTE }
{********************************************************************}
function quit(ch : char) : boolean;
{ THIS FUNCTION DETERMINES WHETHER OR }
begin { FUNCTION QUIT } { NOT THE USER WISHES TO CONTINUE }
if upcase(ch) = 'Y' then { USING THE CALCULATOR.}
quit := false;
if upcase(ch) = 'N' then
quit := true
end; { FUNCTION QUIT }
{********************************************************************}
begin { MAIN }
clrscr; { CLEARS THE SCREEN. }
flag := true;
assign(outfile,'CON' ); { ASSIGNS OUTPUT TO THE SCREEN. }
rewrite(outfile);
while flag do begin { AS SOON AS THE USER SAYS 'Y' }
writeln(outfile); { FLAG WILL BECOME FALSE. }
writeln(outfile);
write(outfile,' COMPUTE > '); { USER PROMPT.}
read(kbd,oprand1);
writeln(outfile,compute(oprand1,outfile):1:1);
write(outfile,' QUIT? (Y/N) '); { USER PROMPT.}
read(kbd,ch);
read(kbd,ch);
flag := quit(ch); { ASSIGNS FUNCTION QUIT.}
write(outfile,ch);
end; { WHILE }
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!
_____________________

|