Computer Science Canada Faulty Loop! HELP! |
| Author: | Nikola [ Sat Mar 07, 2009 7:15 pm ] | ||
| Post subject: | Faulty Loop! HELP! | ||
I just cant find what I'm doing wrong here. Im trying to make it so if the user inputs a number greater than 25 it will start back at 1. The problem i face though is that if someone posts 60 for example the end result is still greater than 25. So I made a loop to work untill the inputted number is less than 25 but it just wont work! Please try and evaluate the code. Thanks again!
|
|||
| Author: | Euphoracle [ Sat Mar 07, 2009 7:32 pm ] |
| Post subject: | RE:Faulty Loop! HELP! |
Why not just set it to 1? int_num = 1; |
|
| Author: | Nikola [ Sat Mar 07, 2009 7:49 pm ] |
| Post subject: | RE:Faulty Loop! HELP! |
The point isnt to make it 1 if the number is greater than 25 it is to make it run back 25 digits. so if someone inputs 40 it will post 15. It subtracts each time untill the final number is 25 or less. |
|
| Author: | Euphoracle [ Sat Mar 07, 2009 10:26 pm ] |
| Post subject: | RE:Faulty Loop! HELP! |
int_num -= (25 * (int)(int_num / 25)) ? |
|
| Author: | Nikola [ Sat Mar 07, 2009 10:45 pm ] |
| Post subject: | RE:Faulty Loop! HELP! |
nope still wont work i just need the loop to be fixed so it takes 25 from int_num untill int_num is 25 or less |
|
| Author: | Euphoracle [ Sun Mar 08, 2009 2:27 am ] | ||||
| Post subject: | RE:Faulty Loop! HELP! | ||||
Output
|
|||||
| Author: | Nikola [ Sun Mar 08, 2009 11:35 am ] |
| Post subject: | RE:Faulty Loop! HELP! |
i dont understand why would i need it in turing? |
|
| Author: | andrew. [ Sun Mar 08, 2009 11:47 am ] |
| Post subject: | RE:Faulty Loop! HELP! |
It's just an example. Instead of posting the full solution in Java, he did it in Turing so you have to do some work. |
|
| Author: | Ktomislav [ Sun Mar 08, 2009 5:38 pm ] | ||||
| Post subject: | Re: Faulty Loop! HELP! | ||||
Why not just use
or
I don't know which is right. |
|||||
| Author: | Euphoracle [ Sun Mar 08, 2009 7:54 pm ] | ||||
| Post subject: | Re: Faulty Loop! HELP! | ||||
Ktomislav @ Sun Mar 08, 2009 5:38 pm wrote: Why not just use
or
I don't know which is right. He said he wanted to subtract The second one is right for java, first one for turing XD |
|||||
| Author: | Dark [ Thu Mar 12, 2009 8:24 pm ] | ||
| Post subject: | Re: Faulty Loop! HELP! | ||
|
|||