Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Computer Studies Assignment Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ManvirS




PostPosted: Sat Nov 14, 2015 6:36 pm   Post subject: Computer Studies Assignment Help

What is it you are trying to achieve?
I got an assignment from my teacher and I don't understand how to do this question.


What is the problem you are having?
I think I wrote this wrong, but whenever I enter any 3 side lengths, it always shows up as a triangle, even if it's not.


Describe what you have tried to solve this problem
I went through my code to see if something was wrong, but I don't understand why my program isn't working.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:


%A program that has the user enter three lengths of sides. The program determines whether the figure is a triangle.

%Asks the user to enter the length of side 1
loop
    put "Please enter the length of side 1: " ..
    var side1 : real
    get side1

    %Asks the user to enter the length of side 2
    put "Please enter the length of side 2: " ..
    var side2 : real
    get side2

    %Asks the user to enter the length of side 3
    put "Please enter the length of side 3: " ..
    var side3 : real
    get side3

    %Calculates whether the figure is a triangle or not
    if (side1 + side2 > side3)
            or (side2 + side3 > side1)
            or (side1 + side3 > side2) then
        put "This figure is a triangle."
        put ""

    elsif (side1 + side2 < side3)
            or (side2 + side3 < side1)
            or (side1 + side3 < side2) then
        put "This figure is not a triangle."
        put ""
    end if
end loop



Please specify what version of Turing you are using
Turing 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
xSavage




PostPosted: Sun Nov 15, 2015 8:37 am   Post subject: Re: Computer Studies Assignment Help

Instead of putting elsif try putting else, it's much easier. So this is what you would have :

else then
put "This is not a triangle."
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: