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

Username:   Password: 
 RegisterRegister   
 Turing and Conditions. Please help me.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
varman




PostPosted: Sun Dec 04, 2011 6:19 pm   Post subject: Turing and Conditions. Please help me.

What is it you are trying to achieve?
I really need help with this condition question in a turing e-book


What is the problem you are having?
This is the question:
Write a program to output a backwards count by 5s from 100 down to 5. Modify it so that you count from 100 down to 50. Modify it so that before you start the count you can input a number between 100 and 50 so that the program will stop when the count would be less than the number input. For example the execution might be like this:
What number do I stop at? 82
Stop when count less than 82
100
95
90
85


Describe what you have tried to solve this problem
I tried it a couple times without like. I got the part where you had to count down to 5 and to 50, but I don`t get the last part of the question. Like how to get the user to input the number they would like for it to count down to. Please help me. I think that it has something to do with the mod function.





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

Turing:


<var modifiednumber: int := 100
var stophere: int
loop
    put "Enter the number you would like to count down to, it has to be in between 50 and 100"
    get stophere
    put "Stop when count less than ", stophere
    exit when modifiednumber < stophere
    modifiednumber:= modifiednumber-5
    put modifiednumber
end loop
   
>



Please specify what version of Turing you are using
4.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Dec 04, 2011 6:32 pm   Post subject: RE:Turing and Conditions. Please help me.

code:

put "Enter the number you would like to count down to, it has to be in between 50 and 100"

How many times do you want to ask this? If it's just once, why is it inside of a loop (do something many times).
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
huskiesgoaler34




PostPosted: Sun Dec 04, 2011 7:17 pm   Post subject: Re: Turing and Conditions. Please help me.

You should use a decreasing for statement:

code:


for decreasing y : 100 .. stophere by 5
    put y
end for
huskiesgoaler34




PostPosted: Sun Dec 04, 2011 7:34 pm   Post subject: Re: Turing and Conditions. Please help me.

The for statement is just a type of loop that is ran a specific amount of times (therefore calling it a counted loop). This will allow you to run the loop until you reach stophere, your number input.
varman




PostPosted: Sun Dec 04, 2011 7:52 pm   Post subject: RE:Turing and Conditions. Please help me.

@Tony
It is because the numbers need to be shown decreasing.
huskiesgoaler34




PostPosted: Sun Dec 04, 2011 7:58 pm   Post subject: Re: RE:Turing and Conditions. Please help me.

varman @ Sun Dec 04, 2011 7:52 pm wrote:
@Tony
It is because the numbers need to be shown decreasing.


I know that the question is directed at Tony but I felt that I could clear it up faster because I'm already online.

Where the OP placed his put/get statement has no effect on the numbers being shown in a decreasing fashion. It would have no impact on how he would get the numbers to decrease by 5 to the value of stophere.

PS, I see that you are new to the board (only 2 posts). Welcome!
Tony




PostPosted: Sun Dec 04, 2011 8:05 pm   Post subject: RE:Turing and Conditions. Please help me.

That doesn't even address the question I posed.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
huskiesgoaler34




PostPosted: Sun Dec 04, 2011 8:17 pm   Post subject: Re: RE:Turing and Conditions. Please help me.

My response was geared towards answering

varman wrote:

@Tony
It is because the numbers need to be shown decreasing.


Varman asked if the OP's code had to do with the numbers being shown decreasing and I simply said no.
I don't see how Varman's question relates to your original response at all.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Dec 04, 2011 8:22 pm   Post subject: RE:Turing and Conditions. Please help me.

varman @ Sun Dec 04, 2011 6:19 pm wrote:

loop
put "Enter the number you would like to count down to, it has to be in between 50 and 100"
...

Tony @ Sun Dec 04, 2011 6:32 pm wrote:

How many times do you want to ask this?

varman @ Sun Dec 04, 2011 7:52 pm wrote:
@Tony
[herp derp, not a number]


@huskiesgoaler34 -- varman _is_ the OP.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
huskiesgoaler34




PostPosted: Sun Dec 04, 2011 8:24 pm   Post subject: Re: RE:Turing and Conditions. Please help me.

My mistake then.
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  [ 10 Posts ]
Jump to:   


Style:  
Search: