Computer Science Canada need help with my for sequence to correspond with my year for loop |
Author: | Velocity [ Tue Nov 15, 2011 6:08 pm ] | ||
Post subject: | need help with my for sequence to correspond with my year for loop | ||
What is it you are trying to achieve? For the interest how do i make it so that interest will go up by 1 for each year so for example if the interest is 10 in year 1 then the interest in year 2 will be 11, and in year 3 it will be 12... and so on ^^^^ I also need to put this in a for statement What is the problem you are having? adding a counter into a 1 .. interest for statement + 1 Describe what you have tried to solve this problem made a for statement with a +1 in its loop for every year
Please specify what version of Turing you are using 4.1.1a |
Author: | Aange10 [ Tue Nov 15, 2011 6:24 pm ] | ||
Post subject: | RE:need help with my for sequence to correspond with my year for loop | ||
First and foremost, there's no reason to make a new thread for this; generally when you're working with the same source code you did ten minutes ago, you ask your next question in the same thread. Velocity wrote: Describe what you have tried to solve this problem made a for statement with a +1 in its loop for every year And where did you do this? It's not in the source code you provided; ultimately, this would be the answer. Example:
|
Author: | Velocity [ Tue Nov 15, 2011 6:35 pm ] |
Post subject: | RE:need help with my for sequence to correspond with my year for loop |
That's not what i was looking for. Here, i'll just tell you the question that im working on and you tell me if im on the right track. Write a program that inputs and amount of money (initial deposit), an interest rate and a number of years and then computes the bank blance at the end of each year for the number of years indicated. Output for each year (in a table) the number of the year, the balance at the beginning of the year, the interest earned for the year, and the blance at the end of the year. for example your table might look like this if the input was $100, 10%, 2 years : Year Starting Balance Interest Final Balance 1 100 10 110 2 110 11 121 |
Author: | Aange10 [ Tue Nov 15, 2011 6:47 pm ] | ||
Post subject: | RE:need help with my for sequence to correspond with my year for loop | ||
Hmm, I'll lay out a track for you. And if you need help filling in the blanks, you can ask here.
|
Author: | Velocity [ Tue Nov 15, 2011 8:06 pm ] |
Post subject: | RE:need help with my for sequence to correspond with my year for loop |
the part that i am stuck on for this whole time is the 6th step that you displayed. I dont know how to put that onto the screen using the for statement that i indicated with 1 .. years |
Author: | Tony [ Tue Nov 15, 2011 8:14 pm ] |
Post subject: | RE:need help with my for sequence to correspond with my year for loop |
wouldn't it be the same for any other for-statement? How is "for i: 1 .. years" different from "for i: 1 .. 10" ? |
Author: | Aange10 [ Tue Nov 15, 2011 8:22 pm ] |
Post subject: | Re: RE:need help with my for sequence to correspond with my year for loop |
Velocity @ 15/11/2011, 7:06 pm wrote: the part that i am stuck on for this whole time is the 6th step that you displayed. I dont know how to put that onto the screen using the for statement that i indicated with 1 .. years
And also in the step itself, I emphasized when to do it, and I took an extra long comment to tell you how. |
Author: | Velocity [ Tue Nov 15, 2011 9:47 pm ] |
Post subject: | RE:need help with my for sequence to correspond with my year for loop |
@ Tony nope, because they have to input an amount and if they input it, then it cannot be 1 .. 10, 1 .. years is the get amount. @ Aange i see what you did but i dont understand how to do the calculation for each year in one single for statement. |
Author: | Aange10 [ Tue Nov 15, 2011 10:23 pm ] | ||||||||||||||
Post subject: | Re: RE:need help with my for sequence to correspond with my year for loop | ||||||||||||||
Velocity @ 15/11/2011, 8:47 pm wrote: @ Tony nope, because they have to input an amount and if they input it, then it cannot be 1 .. 10, 1 .. years is the get amount.
@ Aange i see what you did but i dont understand how to do the calculation for each year in one single for statement. Actually, tony is correct. Tell me if you understand this
What does that output? You must think I'm dumb right now to ask you what 5+5 is. But now realize what you did. You made x = 5 so when
happens, it's storing the number into a variable, just like we stored 5 into x.
So, what would happen is x was a number you gave me? It'd no longer be constant, it'd be a variable. (Huh, what a familiar term...). Is it impossible for that variable to be 10? Nope. Which means tony's thesis is correct. However, lets advance to your problem; Why don't we break down your question once again? Velocity wrote: how to do the calculation for each year in one single for statement how to do the calculation
for each year
in one single [for] statement
Lets put our information together.
Now let's follow Aange's advise, and pretty up the program. [synt-- Well, actually, I think you can do that. (: |