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

Username:   Password: 
 RegisterRegister   
 How do you..
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
thomasb




PostPosted: Mon Jan 24, 2011 3:40 pm   Post subject: How do you..

Use a sentinel value of "-1" to exit.
Sponsor
Sponsor
Sponsor
sponsor
ProgrammingFun




PostPosted: Mon Jan 24, 2011 4:16 pm   Post subject: RE:How do you..

You do not need to create new threads...

if input == -1
exit without doing anything else

else

do everything else

that is the pseudocode....
thomasb




PostPosted: Mon Jan 24, 2011 4:49 pm   Post subject: Re: RE:How do you..

ProgrammingFun @ Mon Jan 24, 2011 4:16 pm wrote:
You do not need to create new threads...

if input == -1
exit without doing anything else

else

do everything else

that is the pseudocode....

How would i put this in my program:


put "Welcome to converter"
var cent : int
put "Please enter the length in centimetres"
get cent
put "the length in inches is " ..
put cent * 2.54
Tony




PostPosted: Mon Jan 24, 2011 4:52 pm   Post subject: RE:How do you..

Presumably the "do everything else" part will be your existing program.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
ProgrammingFun




PostPosted: Mon Jan 24, 2011 5:05 pm   Post subject: Re: RE:How do you..

thomasb @ Mon Jan 24, 2011 4:49 pm wrote:
How would i put this in my program:


put "Welcome to converter"
var cent : int
put "Please enter the length in centimetres"
get cent
put "the length in inches is " ..
put cent * 2.54


Just as Tony said:

Pesudocode:

Welcome

loop
   Plz input length
      get length

   if length <= -1
      Bye Bye!
      exit the loop

   else
      calculations and output
end loop
thomasb




PostPosted: Mon Jan 24, 2011 5:32 pm   Post subject: RE:How do you..

so I have it working now, how can i make it only display then length when its above 0 when i enter -1 to end it still shows the length?

loop
put "Welcome to converter"
var cent : int
put "Please enter the length in centimetres"
get cent
put "the length in inches is " ..
put cent * 2.54
if cent <= -1
then
exit
else
end if

end loop
Tony




PostPosted: Mon Jan 24, 2011 5:42 pm   Post subject: RE:How do you..

I think simply reading that code out loud to yourself will answer that question.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
thomasb




PostPosted: Mon Jan 24, 2011 6:36 pm   Post subject: Re: RE:How do you..

Tony @ Mon Jan 24, 2011 5:42 pm wrote:
I think simply reading that code out loud to yourself will answer that question.

ive got no idea.. seems fine to me but idk what i have to change
Sponsor
Sponsor
Sponsor
sponsor
ProgrammingFun




PostPosted: Mon Jan 24, 2011 6:53 pm   Post subject: Re: RE:How do you..

Put the following right beside you code and you will see what you are doing wrong:

ProgrammingFun @ Mon Jan 24, 2011 5:05 pm wrote:

Pesudocode:

Welcome

loop
   Plz input length
      get length

   if length <= -1
      Bye Bye!
      exit the loop

   else
      calculations and output
end loop
thomasb




PostPosted: Mon Jan 24, 2011 7:08 pm   Post subject: RE:How do you..

thank you I think i got it!!:

put "Welcome to converter"
loop
var lengt : int
put "Please input the length centimetres"
get lengt
if lengt <= -1
then
exit
else
put "the length in inches is " ..
put lengt * 2.54
end if

end loop
ProgrammingFun




PostPosted: Mon Jan 24, 2011 7:15 pm   Post subject: Re: RE:How do you..

thomasb @ Mon Jan 24, 2011 7:08 pm wrote:
thank you I think i got it!!:


Ur Welcome. BooHoo Canada
Raknarg




PostPosted: Thu Feb 17, 2011 8:47 pm   Post subject: RE:How do you..

One thing your going to need with programming: The order always matters. if its not doing stuff at the right time, you probs just have to move the statement elsewhere.
huskiesgoaler34




PostPosted: Thu Feb 17, 2011 8:53 pm   Post subject: Re: How do you..

Your bang on raknarg. I also find that a lot of beginners tend to over think how to solve their problems. I had that problem but I am getting better at planning my programs, then completing then using pseudo code or flow charts. The more experience you have, the easier the algorithm solving will be. Besides, you won't have that many logic errors to deal with anymore.
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  [ 13 Posts ]
Jump to:   


Style:  
Search: