locked
How to solve the problem on VB.Net? RRS feed

  • Question

  • Interest on a loan is paid on a declining balance, and hence a loan with an interest rate of, say, 14% can cost significantly less than 14% of the balance. Write the program that takes a loan amount and interest rate as input and then outputs the monthly payments and balance of the loan until the loan is paid off. Assume that the monthly payments are 1/20th of the original loan amount and that any amount in excess of the interest is credited toward decreasing the balance due. Thus, on a loan of $20,000, the payments would be $1,000 a month. If the interest rate is 10%, then each month the interest is 1/12th of 10% of the remaining balance. The 1st month (10% of $20,000)/12, or $166.67, would be paid in interest, and the remaining $833.33 would be (10% of $19,166.67)/12, and so forth. Also, have the program output the total interest paid over the life of the loan. Finally, determine what simple annualized percentage of the original loan balance was paid in interest. For example, if $1,000 was paid in the interest on a $10,000 loan and it took 2 years to pay off, then the annualized interest is $500, which is 5% of the $10,000 loan amount.
    Sunday, December 7, 2008 12:03 PM

Answers

  • Is this your result?
    1 Module Homework  
    2   Sub Main()  
    3     Dim month% = 0, tcredit# = 0, ccredit#  
    4 Input:  
    5     Const rate% = 20  
    6     Console.Write("Input loan and interest rate separated by comma: ")  
    7     Dim input$() = Console.ReadLine().Split(",")  
    8     Dim l#, i% : If Not (Double.TryParse(input(0), l) And _  
    9                          Integer.TryParse(input(1), i)) Then GoTo Input  
    10     Dim r# = l, b# = l / 20  
    11     While r > 0  
    12       month += 1  
    13       ccredit = (i * r) / (100 * rate)  
    14       Console.WriteLine("{0:D2}: {1:C2} +> {2:C2}", month, b, ccredit)  
    15       tcredit = tcredit + ccredit  
    16       r -= b  
    17     End While 
    18     Console.WriteLine("Payments in interest: {0:C3}", tcredit)  
    19     Console.WriteLine("Annualised interest: {0:C2}", (12 * tcredit) / rate)  
    20     Console.WriteLine("Press any key or space to new calculation")  
    21     If Console.ReadKey().Key = ConsoleKey.Spacebar Then GoTo Input  
    22   End Sub 
    23 End Module 


    regards, Matt
    Posting you abusive right now, and all of your posts!
    • Edited by konikula Monday, December 8, 2008 1:49 AM
    • Marked as answer by jahn P Monday, December 8, 2008 2:42 PM
    Monday, December 8, 2008 1:36 AM

All replies

  • jahn P,

    We are NOT going to do your homework for you.

    Regards,

    Adjutor

    • Proposed as answer by Adjutor Sunday, December 7, 2008 12:59 PM
    Sunday, December 7, 2008 12:59 PM
  • I second that!  If you have a specific question regarding coding in Visual Basic then we would be glad to answer it.
    • Proposed as answer by konikula Tuesday, December 9, 2008 5:21 PM
    Sunday, December 7, 2008 3:55 PM
  •  Yes, but this is hopefully my homework ;)
    Posting you abusive right now, and all of your posts!
    Monday, December 8, 2008 12:43 AM
  • Is this your result?
    1 Module Homework  
    2   Sub Main()  
    3     Dim month% = 0, tcredit# = 0, ccredit#  
    4 Input:  
    5     Const rate% = 20  
    6     Console.Write("Input loan and interest rate separated by comma: ")  
    7     Dim input$() = Console.ReadLine().Split(",")  
    8     Dim l#, i% : If Not (Double.TryParse(input(0), l) And _  
    9                          Integer.TryParse(input(1), i)) Then GoTo Input  
    10     Dim r# = l, b# = l / 20  
    11     While r > 0  
    12       month += 1  
    13       ccredit = (i * r) / (100 * rate)  
    14       Console.WriteLine("{0:D2}: {1:C2} +> {2:C2}", month, b, ccredit)  
    15       tcredit = tcredit + ccredit  
    16       r -= b  
    17     End While 
    18     Console.WriteLine("Payments in interest: {0:C3}", tcredit)  
    19     Console.WriteLine("Annualised interest: {0:C2}", (12 * tcredit) / rate)  
    20     Console.WriteLine("Press any key or space to new calculation")  
    21     If Console.ReadKey().Key = ConsoleKey.Spacebar Then GoTo Input  
    22   End Sub 
    23 End Module 


    regards, Matt
    Posting you abusive right now, and all of your posts!
    • Edited by konikula Monday, December 8, 2008 1:49 AM
    • Marked as answer by jahn P Monday, December 8, 2008 2:42 PM
    Monday, December 8, 2008 1:36 AM
  • But I am not really offending Adjutor & Dig-Boy, I agree with them: you do evil yourself not doing it yourself. I only responded for your text input was very huge problem to parse, but attracted me by exactness and accuracy. So I did it, not regarding if it agrees with excercise, only in order to check if I can understand such speech, which is very ... difficult for people which are working with arrays and module more than plus and integer ;)
    Posting you abusive right now, and all of your posts!
    • Marked as answer by jahn P Monday, December 8, 2008 2:41 PM
    • Unmarked as answer by jahn P Monday, December 8, 2008 2:41 PM
    Monday, December 8, 2008 1:43 AM
  • Next Problem:
    The Fibonacci nos. Fn are defined as follows: F0 is 1, F1 is 1, & F(i+2) = F1 + F(i+1), for i = 0, 1, 2, ... In other words, each no. is the sum of the previous 2 nos. The 1st few Fibonacci nos. are 1, 1, 2, 3, 5, & 8. These nos. occur as certain population growth rates. If a population has no deaths, then the series shows the increase in population after each generation. A generation is the time it takes a member to reach reproducing age. The formula applies most straightforwardly to asexual reproduction at a rate of one offspring per generation. In any event, the green crud population grows at that rate & produces one generation every 5 days. Hence if a green crud population starts out as 10 lbs. of crud, in 15 days, 30 lbs.; in 20 days, 50 lbs., & so forth. Write the program that takes the initial size of a green crud population (in lbs.) & a no. of days. Assume that the population size is the same for 4 days & then increases every 5th day. 0:-)
    • Edited by jahn P Monday, December 8, 2008 3:09 PM
    Monday, December 8, 2008 2:40 PM
  • Ok, this is stupid we do NOT do homework problems.
    • Proposed as answer by konikula Tuesday, December 9, 2008 5:21 PM
    Monday, December 8, 2008 2:51 PM
  • Ok I am sorry for my output in past TInterface actually again Marshalling thread on "not doing hw's", and I am begging for forgiveness you both, Dig-Boy & Adjutor.

    But I will surely take a look at this, I am interested probably ;) But cannot really promise, for fibonacci is one from things doing my ear wrong/ P
    Posting you abusive right now, and all of your posts!
    • Proposed as answer by konikula Tuesday, December 9, 2008 5:21 PM
    Monday, December 8, 2008 5:24 PM
  • Yep interesting. I will try your next sample.
    Posting you abusive right now, and all of your posts!
    Tuesday, December 9, 2008 5:19 PM
  • Hi again. Here is solution. Do you have another interesting homework :)?
    Sub Main()  
     Input:  
      Console.Write("Input green crud population width & related time frame in comma fmt_> ")  
      Dim input$() = Console.ReadLine().Split(","c)  
      Dim p%, T% : If Not (Integer.TryParse(input(0), p) AndAlso _  
                           Integer.TryParse(input(1), T)) Then GoTo Input  
     
      Dim φA As UInteger = p, φP, φL As UInteger  
      For n As Integer = 1 To T  
        If n Mod 5 = 0 Then 
         φL = φP : φP = φA  
         φA = φL + φP  
         Console.WriteLine("Day {0:D2}: population width = {1:D}", n, φA)  
        End If 
      Next 
      Console.WriteLine("Press spacebar to resume calculation, any key to exit")  
      If Console.ReadKey().Key = ConsoleKey.Spacebar Then GoTo Input  
      'if we would wanted to find fib predecessor from generation frame & population width,  
      'we would needed also initial population width to narrow probable rows to single result  
    End Sub 

    best regards, matej
    Posting you abusive right now, and all of your posts!
    • Proposed as answer by konikula Thursday, December 11, 2008 7:56 PM
    Thursday, December 11, 2008 7:54 PM