Computer Science Canada

Some one look at this i need help please

Author:  Slnj [ Wed Mar 24, 2010 9:18 pm ]
Post subject:  Some one look at this i need help please

What is it you are trying to achieve?
im trying to finish my homework Razz


What is the problem you are having?
i do not understand this question so i do not know how to code it

the question:

Write a program that prompts for an initial amount of money and an annual interest rate, then calculates how much money will be accumulated in 20 years.

Also for this i have to use the " For loop "

Describe what you have tried to solve this problem
i tried asking friend but they don't get it either =/


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

I took a shot at it but failed.. so confused

Turing:


var initial, annual,years: int
years := 20
put "What is the initial amount of money? "
get initial
put "what is the annual interest rate? "
get annual

for accumulated : initial..years by annual
put accumulated
end for
   



Please specify what version of Turing you are using
latest version i think

Author:  ProgrammingFun [ Wed Mar 24, 2010 9:22 pm ]
Post subject:  RE:Some one look at this i need help please

Just so you know:

At this forum, we are here to HELP you not DO the work for you.

So if you have any specific questions, feel free to ask.

HINT: You do not have to use for. And if you want to keep years constant, you could declare it as:

Turing:

const years: int := 20

Author:  Slnj [ Wed Mar 24, 2010 9:33 pm ]
Post subject:  RE:Some one look at this i need help please

i get what yours saying but can you explain how i could do this i don't understand the question so i don't know how to code it. my teacher also told me to use for loop or she won't mark it =/

Author:  Tony [ Wed Mar 24, 2010 10:36 pm ]
Post subject:  Re: RE:Some one look at this i need help please

Slnj @ Wed Mar 24, 2010 9:33 pm wrote:
what yours saying

What. Was. That?

An explanation for the question: when someone invests some money, that amount typically earns some profit, as a percent increase. That is known as interest. So if I started with $100 and the interest rate is 10% per year, then after a year I would have $110. If I waited another year, it would be $121. Etc. The question asks about the amount I would end up with in 20 years.

Author:  Slnj [ Thu Mar 25, 2010 4:43 pm ]
Post subject:  Re: RE:Some one look at this i need help please

Tony @ Wed Mar 24, 2010 10:36 pm wrote:
Slnj @ Wed Mar 24, 2010 9:33 pm wrote:
what yours saying

What. Was. That?

An explanation for the question: when someone invests some money, that amount typically earns some profit, as a percent increase. That is known as interest. So if I started with $100 and the interest rate is 10% per year, then after a year I would have $110. If I waited another year, it would be $121. Etc. The question asks about the amount I would end up with in 20 years.


Thanks !! i finally understand. and also i don't use grammar/spelling online so sorry for my bad grammar/spelling

Author:  Slnj [ Thu Mar 25, 2010 4:43 pm ]
Post subject:  RE:Some one look at this i need help please

Also what can i use to declare a decimal? int won't work

Author:  Tony [ Thu Mar 25, 2010 4:51 pm ]
Post subject:  RE:Some one look at this i need help please

in Turing, the variable type you are looking for is called real

Author:  Slnj [ Thu Mar 25, 2010 5:01 pm ]
Post subject:  Re: RE:Some one look at this i need help please

Tony @ Thu Mar 25, 2010 4:51 pm wrote:
in Turing, the variable type you are looking for is called real


ohhh yea!! forgot about that didn't use it for a while so yea and thanks again! also can you help me understand a new questions =/?

questions:

Write a program that inputs a dollar amount and outputs how the amount can be represented using the fewest number of bills and coins. Hint: Use the mod and div commands.

i do not know what mod or div is used for =/

Author:  Tony [ Thu Mar 25, 2010 5:12 pm ]
Post subject:  RE:Some one look at this i need help please

That's just a hint. You can see what those operations do at those links -- mod and div

Author:  Slnj [ Thu Mar 25, 2010 5:45 pm ]
Post subject:  Re: RE:Some one look at this i need help please

Tony @ Thu Mar 25, 2010 5:12 pm wrote:
That's just a hint. You can see what those operations do at those links -- mod and div


Thank you, going to try coding it but i don't know how to make it give the least amount of bills and coins for the dollar amount

Author:  Tony [ Thu Mar 25, 2010 5:55 pm ]
Post subject:  RE:Some one look at this i need help please

Perhaps you should figure that out before trying to code something. I find it helpful to sketch things out on paper, or to work through a specific example.

If I need $26.31, what bills and coins put together such an amount? (How did you figure that out?)

Author:  Slnj [ Thu Mar 25, 2010 8:29 pm ]
Post subject:  RE:Some one look at this i need help please

but i don't get it, say someone input like $100 how would my program know to give 2 $50 bills ?

Author:  syntax_error [ Thu Mar 25, 2010 9:00 pm ]
Post subject:  RE:Some one look at this i need help please

Think logically how would you do this type of question with pen and paper. Say for an amount of $47.82

Lets assume we are in the Canadian monetary system. The highest legal tender we have is of $100 then $50 then $20 then $10 and lastly $5.

You have a amount of $47.82 you check it and see $100 is too large as well is $50, then you see $20 is smaller and you subtract it from the total; leaving you with 1 x $20 and $27.82 which again you check though starting with the highest you left at which was $20 and it still smaller so you subtract it from the total.

Now you have 2 x $20 and $7.82 which you put though the check again and see that 10 is too large and 5 is the smallest left.

And so on you continue in your head to make chance the computer does the same.


Try to re-create that process in your code.

Author:  Slnj [ Thu Mar 25, 2010 9:16 pm ]
Post subject:  Re: RE:Some one look at this i need help please

syntax_error @ Thu Mar 25, 2010 9:00 pm wrote:
Think logically how would you do this type of question with pen and paper. Say for an amount of $47.82

Lets assume we are in the Canadian monetary system. The highest legal tender we have is of $100 then $50 then $20 then $10 and lastly $5.

You have a amount of $47.82 you check it and see $100 is too large as well is $50, then you see $20 is smaller and you subtract it from the total; leaving you with 1 x $20 and $27.82 which again you check though starting with the highest you left at which was $20 and it still smaller so you subtract it from the total.

Now you have 2 x $20 and $7.82 which you put though the check again and see that 10 is too large and 5 is the smallest left.

And so on you continue in your head to make chance the computer does the same.


Try to re-create that process in your code.


ohhh i see ok, but i don't know how to code it does

Quote:

You have a amount of $47.82 you check it and see $100 is too large as well is $50, then you see $20 is smaller and you subtract it from the total; leaving you with 1 x $20 and $27.82 which again you check though starting with the highest you left at which was $20 and it still smaller so you subtract it from the total.
[/quote]

Author:  syntax_error [ Thu Mar 25, 2010 9:19 pm ]
Post subject:  RE:Some one look at this i need help please

You compare data.

if var1 > var2 then do bhal
if not then do bhal2

etc.

Author:  Slnj [ Fri Mar 26, 2010 5:54 am ]
Post subject:  Re: RE:Some one look at this i need help please

syntax_error @ Thu Mar 25, 2010 9:19 pm wrote:
You compare data.

if var1 > var2 then do bhal
if not then do bhal2

etc.


i didn't learn the 'if' statement yet, I have to use all the methods i learned which are for loops, loops, and all the simple stuff.

Author:  Turing_Gamer [ Fri Mar 26, 2010 7:37 am ]
Post subject:  RE:Some one look at this i need help please

if statement is very self explanitory. With this command you can do a function only when certain parameters are met. For example...
Turing:
var num1, num2 : int
put " Enter a number..."
get num1
put " Enter another number..."
get num2
%PAY ATTENTION HERE
if num1 > num2 then % Ask for specific test
    put " The first number is bigger than the second."
elsif num1 < num2 then % Ask for another specific test
    put " The second number is bigger than the first."
elsif num1 = num2 then % Ask for again another specific test
    put " Both numbers are the same"
else % If all else fails
    put " SYNTAX ERROR!!"
end if

Author:  USEC_OFFICER [ Fri Mar 26, 2010 11:47 am ]
Post subject:  RE:Some one look at this i need help please

How do you not learn if statements! The if statement is the simplest part of Turing! How do you even exit from a loop! I shouldn't end each sentence with an exclamation mark! *Shocked face*

Author:  Slnj [ Fri Mar 26, 2010 2:46 pm ]
Post subject:  RE:Some one look at this i need help please

k nvm im just going to use the if statement.. here's what i got so far but having trouble

Quote:
var money, a, b : real
put "What is the amount of money? "
get money

if money >100 then
a := money div 100 put a ," hundered dollar bill "
elsif a >50 then
b := a mod 50 put b, " fifty dollar bill "
end if


: