Are you blogging on PH? Get your free blog.

View \SHAPES4.PAS

This is the second disk of the PASCAL TUTOR system. It has the

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


(* Chapter 13 - Program 4 *)
program Calculate_Area_Of_Shapes;

uses Areas,Crt,Turbo3;

var In_Char : char;
    Length,Width,Height,Base,Radius : real;

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 UpCase(In_Char) of
       'S' : begin
             Write('Square   Enter length of side ');
             Readln(Length);
             Writeln('The area is ',Area_Of_Square(Length):12:4);
             end;

       'R' : begin
             Write('Rectangle   Enter width ');
             Readln(Width);
             Write('Enter height ');
             Read(Height);
             Writeln('    The area is ',
                            Area_Of_Rectangle(Width,Height):12:4);
             end;

       'T' : begin
             Write('Triangle     Enter base ');
             Readln(Base);
             Write('Enter height ');
             Read(Height);
             Writeln('    The area is ',
                            Area_Of_Triangle(Base,Height):12:3);
             end;

       'C' : begin
             Write('Circle    Enter radius ');
             Readln(Radius);
             Writeln('The area is ',Area_Of_Circle(Radius):12:3);
             end;

       'Q' : Writeln('Quit');
       else Writeln(' undefined entry');
      end;
   until (In_Char = 'Q') or (In_Char = 'q');
end(* of main program *)

corner
© 1996-2008. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin.
bootstrapLabs Logo A bootstrapLabs project.