Please help: Type missmatch 
Author Message
 Please help: Type missmatch

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. -->');
     Readln(A, B, C);
     If (C < A) or (C < B)
        Then Writeln('Please put largest last.')
  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.

 -------------
Please respond via email.

Thanks,
Michael



Wed, 18 Jun 1902 08:00:00 GMT  
 Please help: Type missmatch

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. -->');
>     Readln(A, B, C);
>     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
the values FALSE or TRUE.  From the online help we have:

  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  
 Please help: Type missmatch


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. -->');
>>     Readln(A, B, C);
>>     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
>the values FALSE or TRUE.  From the online help we have:

>  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  
 
 [ 3 post ] 

 Relevant Pages 

1. Registering types, please help!

2. Somerone, Please help me to verify a abstract data type program

3. Please Please, help me with memo-fields, real problem

4. Please, please help me with this code.

5. please, I beg of you help me please.

6. PLEASE PLEASE HELP ME

7. Please Please help me

8. Help Drag and drop please please

9. changing real type data to word type

10. Money field type same as Currency data type??

11. numeric field type same as float type??

12. Types and Type-casting ...

 

 
Powered by phpBB® Forum Software