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

Username:   Password: 
 RegisterRegister   
 Help Completing The Exercise In Turing
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Honsly




PostPosted: Mon Mar 04, 2013 6:21 pm   Post subject: Help Completing The Exercise In Turing

What is it you are trying to achieve?
I am trying to complete this Turing exercise.
Please feel free to change the code in any way and to repost any code which you think works.
Thank You, need it for tomorrow.

What is the problem you are having?
I have it going pretty well but then it messes up.
Here is the exercise:
11. A homeowner takes out a mortgage for $120,000 at 10 3/4% per year. At the end of each year an amount of $24,000 is paid. Write a program to show how the mortgage is paid off, year by year, until nothing is owing.

Describe what you have tried to solve this problem
I have tried to create the program but it skips one amount and I don't know why.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Here is the best i could do but i don't know why it messes up in the middle. It jumps down by 48 000 instead of 24 000 after $72 000.

Turing:


const pay : real := 24000
var mortgage : real := 120000
var yearr : int := 0
var newpay : real := 120000
var tot : real := 120000
loop
    yearr := yearr + 1
    newpay := mortgage - pay
    mortgage := tot - pay
    tot := mortgage - pay
    put "This is year #",yearr,"."
    put "You have paid $24000 for year #",yearr,"."
    put "You still have to pay $",newpay,"."
    delay(1000)
    if mortgage <= 0 then
        put "This is year #",yearr + 1,"."
        put "You have paid off your mortgage!"
    end if
    exit when mortgage <= 0
end loop





Please specify what version of Turing you are using
I am using Turing 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
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 1  [ 1 Posts ]
Jump to:   


Style:  
Search: