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

Username:   Password: 
 RegisterRegister   
 Loops
Index -> Programming, Turing -> Turing Help
Goto page 1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Angel




PostPosted: Wed Jan 07, 2004 12:48 am   Post subject: Loops

I have a bug in my program and don't know how to fix it. This is it:

What's supposed to happen is that when the user makes a selection between quizes 1 and 2, and they type in a wrong number, the program continues to ask the user to re-enter the number until they enter 1 or 2. But when they do enter it, nothing happens. It doesn't go to quiz 1 when they enter 1 and it doesn't clear when they enter 2. Do you know how I can fix that and make sure that it does that stuff when the user finally enters the correct number? If you do, can you please make the necessary changes in the program and post it? Thanks.
Sponsor
Sponsor
Sponsor
sponsor
shorthair




PostPosted: Wed Jan 07, 2004 11:22 am   Post subject: (No subject)

code:

elsif choice = 2 then
    cls

elsif
        choice >= 2 then
    put "This is not a choice."
    put "Please select another choice:  " ..
    loop
        get choice
        exit when choice = 1 or choice = 2
        put "Please select another choice:  " ..
        if choice = 1 then
            cls
  end if
end loop


LOOK AT THAT ELSIF STATMENT. your code is completly bassakwards, . if htey enter 1 then its gonna have a true statement ,meaning that it will exit the loop NOT HTE IF STATEMENT, you cant exit an if statement with the exit command you need somthing to be true , so not only by entering one does it get out of hte if statement it also gets out of your loop, so hte program finishes , what you need is to add another loop from the first line to the last line so that it will loop back to the tp of the program again.
shorthair




PostPosted: Wed Jan 07, 2004 11:27 am   Post subject: (No subject)

FULLY WORKING VERSION OF YOUR PROGRAM
***I edited out this old version of the code so that the forum dosent look messey and huge***
Angel




PostPosted: Wed Jan 07, 2004 11:39 am   Post subject: (No subject)

Thanks! But no offence... you dun gotta be rude about it! I'm merely a newbe trying to make it in this huge and complicated world of Turing! Wink
shorthair




PostPosted: Wed Jan 07, 2004 11:41 am   Post subject: (No subject)

sorry , but to me it just loked so obvious , im judging it from experiance , sorry about hte comment , Very Happy no hard feelings , but im glad i could help fix your bug
Angel




PostPosted: Wed Jan 07, 2004 12:39 pm   Post subject: (No subject)

Thanks, and no hard feelings Smile
Angel




PostPosted: Wed Jan 07, 2004 12:41 pm   Post subject: (No subject)

I've run into another problem. I tried the program you posted and it works, but when I editted it a bit (I added questions for the second quiz), it shows me an error that says: Extra 'end' So when I delete the end loop the program works again, but it's like the problem I was having before: nothing happens when the user puts in the correct number. I'll paste the program again and please see if you can modify it again to display the correct result. Thanks.



:Thinking:
shorthair




PostPosted: Wed Jan 07, 2004 12:51 pm   Post subject: (No subject)

Let me have this one guys , il have it up in 1 hour okay , thanks
Sponsor
Sponsor
Sponsor
sponsor
Angel




PostPosted: Wed Jan 07, 2004 12:52 pm   Post subject: (No subject)

A whole hour?! But I can wait... as long as I can finally get it to work! Smile
Angel




PostPosted: Wed Jan 07, 2004 2:03 pm   Post subject: (No subject)

Almost done?
shorthair




PostPosted: Wed Jan 07, 2004 2:09 pm   Post subject: (No subject)

here ya go
Very Happy



help1.t
 Description:
HERE YA GO

Download
 Filename:  help1.t
 Filesize:  17.08 KB
 Downloaded:  174 Time(s)

shorthair




PostPosted: Wed Jan 07, 2004 2:10 pm   Post subject: (No subject)

fully done , changes the entire method you did it, please ask questions so that you really understand this , dont just say you know it if you dont
shorthair




PostPosted: Wed Jan 07, 2004 2:12 pm   Post subject: (No subject)

I only actually needed literally 3 minutes , but i had to go out , i changed aabout 20 lines of code , and made procedures out of the quizes , sorry about the delay
Angel




PostPosted: Wed Jan 07, 2004 2:13 pm   Post subject: (No subject)

Crying or Very sad I hate to keep bugging you, but my computer has some stupid firewall on it and I can't download the thing. Can you please just paste the code? SOOO SORRY! Sad
shorthair




PostPosted: Wed Jan 07, 2004 2:14 pm   Post subject: (No subject)

Did you get the source yet -----> its on hte next page
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 3  [ 44 Posts ]
Goto page 1, 2, 3  Next
Jump to:   


Style:  
Search: