home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
pascal2.zip
/
SHAPES3.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-01-15
|
2KB
|
73 lines
program Calculate_Areas;
(* This program is dedicated to Marsha, a student, who
was of tremendous help during the debugging stage of
the text and programs. Thanks Marsha!
*)
var In_Char : char;
procedure Area_Of_Square;
var Length,Area : real;
begin
Write('Square Enter length of side ');
Readln(Length);
Area := Length * Length;
Writeln('The area is ',Area:12:4);
end;
procedure Area_Of_Rectangle;
var Width,Height,Area : real;
begin
Write('Rectangle Enter width ');
Readln(Width);
Write('Enter height ');
Read(Height);
Area := Width * Height;
Writeln(' The area is ',Area:12:4);
end;
procedure Area_Of_Triangle;
var Base,Height,Area : real;
begin
Write('Triangle Enter base ');
Readln(Base);
Write('Enter height ');
Read(Height);
Area := 0.5 * Base * Height;
Writeln(' The area is ',Area:12:3);
end;
procedure Area_Of_Circle;
var Radius,Area : real;
begin
Write('Circle Enter radius ');
Readln(Radius);
Area := 3.141592 * Radius * Radius;
Writeln('The area is ',Area:12:3);
end;
begin (* main program *)
repeat
Writeln;
Writeln('Please input the first letter of the selection');
Writeln('Select shape; Square Rectangle Triangle Circle Quit');
Write('Requested shape is ');
Repeat until Keypressed;
Read(Kbd,In_Char);
case In_Char of
'S' : Area_Of_Square;
's' : Area_Of_Square;
'R' : Area_Of_Rectangle;
'r' : Area_Of_Rectangle;
'T' : Area_Of_Triangle;
't' : Area_Of_Triangle;
'C' : Area_Of_Circle;
'c' : Area_Of_Circle;
'Q' : Writeln('Quit');
'q' : Writeln('Quit');
else Writeln(' undefined entry');
end;
until (In_Char = 'Q') or (In_Char = 'q');
end. (* of main program *)