Thread: (Comparing loans with various interest rates)

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    11

    (Comparing loans with various interest rates)

    (Comparing loans with various interest rates) Write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each annual interest rate starting from 5% to 8%, with an increment of 1/8. Suppose you enter the loan amount 10,000 for five years;
    a) Display a table as follows:
    Loan Amount: 10000
    Number of Years: 5

    Interest Rate Monthly Payment Total Payment
    ----------------------------------------------------
    5% 188.71 11322.74
    5.125% 189.28 11357.13
    5.25% 189.85 11391.59

    ...
    7.85% 202.16 12129.97
    8.0% 202.76 12165.83
    The formula to compute the monthly payment is as follows:

    http://www14.0zz0.com/2010/02/26/13/516993313.png

    You don't have to know how this formula is derived. Nonetheless, given the monthly interest rate, number of years, and loan amount, you can use it to compute the monthly payment.
    Compute the total payment, which is the monthly payment multiplied by 12 and multiplied by the number of years.
    I wrote program for first question , can anybody help me with writing program for Q.2? .

    b) If a person can pay monthly around a given amount (for example 200±5), and he wants to take a given loan (for example 10000).
    Let the program find how many years needed (between 5 and 15) and what the value of the annualInterstRate (between 5% and 8% with an increment of 1/8.) supposed to be, to pay the taken loan.
    (Find all the possibilities in which the person can pay).
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
    float m,t;
    float p,w,y,r;
    
    printf("Enter loan amount :-\n");scanf("%f",&p);
    printf("Enter loan period , with years :-\n");scanf("%f",&y);
    printf("Intrest rate  Monthly payment  Total payment\n");
    printf("--------------------------------------------\n");
    
    for(r=5;r<=8;r=r+0.125){
    w=pow((1+(r/(12*100))),(12*y));
    m=((r/(12*100))*p*w)/(w - 1);
    t=m*12*y;
    printf("%.3f\t\t%.2f\t\t%.2f",r,m,t);
    printf("\n");
                           }
    
    return 0;
    }
    Last edited by ccccccc; 02-26-2010 at 11:10 AM.

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    11
    no anyone can help me !!!

  3. #3
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472

    Loans n rates, shudder!

    Come on man its not the best subject to get excited about haha! Several hours hav elapsed since you posted, no further progress? What exactly is it about part2 that gives you trouble? You tackled part one and then gave up? Nothing transfers from earlier?

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    Unless I'm misunderstanding the assignment then b is almost exactly the same as a, except you only print out lines where the monthly payment is below or equal to the inputted amount.

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    11
    _Mike
    but i don't know How i can connect a variables

  6. #6
    Registered User
    Join Date
    Feb 2010
    Posts
    11
    ...............

  7. #7
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    but i don't know How i can connect a variables
    I am sorry man, your words do not make sense, if you are sitting around waiting for a magic answer i doubt it is going to be provided until you put together a more conscise, (and coherent) description of your actual main issue / sticking points with partB as well as any attempt you have made to complete it.

  8. #8
    Registered User
    Join Date
    Feb 2010
    Posts
    11
    I am sorry man, your words do not make sense, if you are sitting around waiting for a magic answer i doubt it is going to be provided until you put together a more conscise, (and coherent) description of your actual main issue / sticking points with partB as well as any attempt you have made to complete it.
    I do not want from you to write my program .. only , I want to understand what is required from the question

  9. #9
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Perhaps this is a poor English issue? Rogster is correct, your last couple of posts do not make rational sense, so it is hard to answer.

    Maybe you should have a look a this:
    How To Ask Questions The Smart Way
    There are translations into about 20 different languages if you look down the page.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  10. #10
    Ultraviolence Connoisseur
    Join Date
    Mar 2004
    Posts
    555
    For question b, you need to determine the number of years needed to accommodate a loan of X with a monthly payment of Y. Once you find the years, Z, you display the results exactly as question 'a' with loan of X and years of Z.

    To find the number of years needed to accommodate a loan of X and stay within a monthly payment of Y +/-5 there are probably many ways. A very simple method could be to simply loop through each year, 5 through 15, calculate the monthly payment for that length of time and see if it matches up with Y +/-5, if so you have a possible answer (you should show all possible loans).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 02-11-2009, 12:54 PM
  2. Programming project help?
    By Debbie Bremer in forum C++ Programming
    Replies: 21
    Last Post: 10-11-2008, 02:48 AM
  3. Compound Interest Formula
    By veronicak5678 in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2007, 05:16 PM
  4. compound interest
    By bliznags in forum C Programming
    Replies: 11
    Last Post: 03-20-2005, 01:46 AM