Author Message

Program PTriples(Input,Output);

Uses CRT;

{ This program is supposed to examine a trio of numbers and determine
whether or not sides of those lengths form a right triangle.  Write
a Boolean function to determine this. }

Var A,B,C:Integer;

Procedure GetTrio(Var A, B, C:Integer);
Begin
Repeat
Write('Enter 3 sides, largest last. -->');
If (C < A) or (C < B)
Until (C > A) and (C > B)
End;

Function Pythag(A, B, C:Integer):Boolean;
Var RightTriangle:Boolean;

Begin
RightTriangle := 'True';
If RightTriangle SQR(A) + SQR(B) = SQR(C)
Then RightTriangle := 'True'
Else RightTriangle := 'False';
Pythag := RightTriangle
End;

Begin
ClrScr;
GetTrio(A, B, C);
Writeln;
Writeln;
Write(A,', ',B,' and ',C, ' do');
If RightTriangle := 'False'
Then Write (' NOT');
Writeln(' make a right triangle.')
End.

-------------

Thanks,
Michael

Wed, 18 Jun 1902 08:00:00 GMT

Quote:

>Program PTriples(Input,Output);

>Uses CRT;

>{ This program is supposed to examine a trio of numbers and determine
>  whether or not sides of those lengths form a right triangle.  Write
>  a Boolean function to determine this. }

>Var A,B,C:Integer;

>Procedure GetTrio(Var A, B, C:Integer);
>Begin
>  Repeat
>     Write('Enter 3 sides, largest last. -->');
>     If (C < A) or (C < B)
>        Then Writeln('Please put largest last.')
>  Until (C > A) and (C > B)

Why not make the program smart enough to put the number in
the right order?  Besides, your statement of work says
nothing about the numbers having to be entered with the
largest number last.

Quote:
>End;

>Function Pythag(A, B, C:Integer):Boolean;
>Var RightTriangle:Boolean;

>Begin
>  RightTriangle := 'True';

A Boolean variable is not a string, nor is it an integer.
In fact it is nothing except an enumeration that can contain

Syntax:
type
Boolean  = (False, True);

So drop the quotes and state:  RightTriangle := True;

Then make similar changes in the way you handle other
Boolean variables.

...red
cc

Wed, 18 Jun 1902 08:00:00 GMT

Quote:

>>Program PTriples(Input,Output);

>>Uses CRT;

>>{ This program is supposed to examine a trio of numbers and determine
>>  whether or not sides of those lengths form a right triangle.  Write
>>  a Boolean function to determine this. }

>>Var A,B,C:Integer;

>>Procedure GetTrio(Var A, B, C:Integer);
>>Begin
>>  Repeat
>>     Write('Enter 3 sides, largest last. -->');
>>     If (C < A) or (C < B)
>>        Then Writeln('Please put largest last.')
>>  Until (C > A) and (C > B)

>Why not make the program smart enough to put the number in
>the right order?  Besides, your statement of work says
>nothing about the numbers having to be entered with the
>largest number last.

Also what happens if A=B=C?

- Show quoted text -

Quote:

>>End;

>>Function Pythag(A, B, C:Integer):Boolean;
>>Var RightTriangle:Boolean;

>>Begin
>>  RightTriangle := 'True';

>A Boolean variable is not a string, nor is it an integer.
>In fact it is nothing except an enumeration that can contain

>  Syntax:
>  type
>    Boolean  = (False, True);

Actually boolean is much more than just enumeration as comparisons are
based on booleans.

Osmo

Wed, 18 Jun 1902 08:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages