Computer Science Canada Need help using Loop as Accumulator and variable storage |
Author: | neozeak [ Sun Apr 24, 2005 8:16 pm ] | ||
Post subject: | Need help using Loop as Accumulator and variable storage | ||
I am writing a program for my compsci class that is basically supposed to recommend a product based upon the answers to two questions, while additionally asking other questions. The program must also provide a cost of the consultation, based upon number of questions answered. Store the final advice generated by the program as a variable. And offer the option to restart the consultation, while keeping the accumulator loop running to tack on additional costs to the consulation. If you are with me so far, you are probably better off than I. here is the code I have as of yet, if you can offer any advice as to how to adapt my code to perform the above results, I would greatly appreciate it.
I have until Wednesday to finish this. But I was trying to finish up a bit early...exams coming up and all. Any help is greatly appreciated. EDIT: Code changed thanks to tokens advice |
Author: | Token [ Sun Apr 24, 2005 9:05 pm ] | ||
Post subject: | |||
i'm not exactly sure what it is you need, but why not have a variable and then add to it each time a question is answered that would give you the total number of questions answered and you can from that figure out the total cost... if this isnt it let us know, and could you please put your code inside code brackets [code ]put your code here[/code ] like that w/o the spaces...
|
Author: | neozeak [ Sun Apr 24, 2005 9:42 pm ] |
Post subject: | |
thanks a lot for your help, and I am sorry about not putting the code correctly. That helps with the accumulator problem I think, but I am supposed to be able to give them the option to start over after the end if they are not happy with the advice given. How would one go about doing that |
Author: | Token [ Mon Apr 25, 2005 6:18 am ] | ||
Post subject: | |||
well what you could do is make the entire program inside 2 loops, and then after each question ask start again? and if the person says yes then exit the first loop which would then take you to the seccond, causing it to start over again, like this
i could only do the first one because i g2g i'll do the rest from school, cya |
Author: | jamonathin [ Mon Apr 25, 2005 8:54 am ] |
Post subject: | |
lol, maybe next time you guys should just upload it from a .t file. |
Author: | Token [ Mon Apr 25, 2005 10:47 am ] |
Post subject: | |
jamonathin: in heinsight, that seems like a good idea lol but i thaught it would be over in one post... gues not lol oh well... hope that helps. |
Author: | jamonathin [ Mon Apr 25, 2005 11:20 am ] |
Post subject: | |
Yesh, it helps very much. |
Author: | neozeak [ Mon Apr 25, 2005 2:29 pm ] |
Post subject: | |
I am only supposed to ask them to restart the program following the last question, additionally the code you posted does not restart the loop upon answering no, is that because you didn't have time to finish? |
Author: | Token [ Mon Apr 25, 2005 2:56 pm ] |
Post subject: | |
Here, try this, i had the right idea, crappy method. |
Author: | neozeak [ Mon Apr 25, 2005 3:42 pm ] |
Post subject: | |
I basically just came to the same conclusion finally, I have been messing with the code for like an hour. So all my problems are solved minus one. How do I save the advice given as a variable? I have looked for a store function or something along those lines and cannot find anything. |
Author: | Token [ Mon Apr 25, 2005 4:44 pm ] | ||
Post subject: | |||
okay well you could save it into a string variable
|
Author: | neozeak [ Mon Apr 25, 2005 6:20 pm ] |
Post subject: | |
this is what it says in the rubric for my project: give some final advice about what products/services to buy based on atleast two answers, storing that final advice as a variable. That to me means that in each particular case i am supposed to store it as a variable after it has been given, as the advice given does vary based upon the responses of the individual. Is there a way to do that? |
Author: | Token [ Mon Apr 25, 2005 7:17 pm ] |
Post subject: | |
mm to me i see this as saying to store the variable that you are sending to this person specifically as per their questions. |