don't have any clue how to do this

This is a discussion on don't have any clue how to do this within the C Programming forums, part of the General Programming Boards category; i need to make a program that asks for the amount of a loan, the interest rate, and the length ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    38

    don't have any clue how to do this

    i need to make a program that asks for the amount of a loan, the interest rate, and the length of the loan using scanf. then i need it to tell me what the monthly payment is.

    i want to use "a" as the amount of the loan, the monthly interest rate is r and n is the length of the loan in months. P is the monthly payment.

    my equation should be this p=a(r((1+r)^n))/((1+r)^n)-1))

    I really don't know what i'm doing... if someone could show me how to do the exponents is the main part. thanks.

  2. #2
    JDD
    JDD is offline
    Registered User
    Join Date
    Oct 2006
    Posts
    25
    Quote Originally Posted by newcstudent
    my equation should be this p=a(r((1+r)^n))/((1+r)^n)-1))
    Are you sure theres no way to simplify the equation?

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    38
    i have no idea. i think it is simplified... it's much easier to visualize as a fraction... the whole first part is over the second part.

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by newcstudent
    if someone could show me how to do the exponents is the main part.
    man pow
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    38
    can you give me a short program using man pow? i've never seen it before... all i know how to use is printf, scanf and fputs.

  6. #6
    JDD
    JDD is offline
    Registered User
    Join Date
    Oct 2006
    Posts
    25
    Quote Originally Posted by Dave_Sinkula
    Ill save you some time, pow(x, y) , computes x to the power of y

    Example: p=a(r((1+r)^n))/((1+r)^n)-1))

    pow((1+r), n);

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    38
    so i would define x as (1+r) and then use y instead of n?

  8. #8
    Registered User
    Join Date
    Oct 2006
    Posts
    38
    is it man pow((1+r), n)
    or is it pow((1+r), n)
    and i put that at the beggining of my function right? next to my curly brace?

  9. #9
    JDD
    JDD is offline
    Registered User
    Join Date
    Oct 2006
    Posts
    25
    Quote Originally Posted by newcstudent
    so i would define x as (1+r) and then use y instead of n?
    No, you could do exactly what i showed you.

    Here's how you would compute that equation, to my knowledge.

    Code:
    p = a (r ( (pow( (1+r), n) ) ) / ( (pow( (1+r), n ) -1 ) ) )
    is it man pow((1+r), n)
    or is it pow((1+r), n)
    and i put that at the beggining of my function right? next to my curly brace?
    No, first you have to get input from the user, about how much the loan is, the interest rate, and lenght.
    Last edited by JDD; 10-09-2006 at 12:35 AM.

  10. #10
    Registered User
    Join Date
    Oct 2006
    Posts
    38
    ok. thanks man. i think i get it=) i really appreciate it... I hate being so elementary all of a sudden. i feel really annoying.

  11. #11
    JDD
    JDD is offline
    Registered User
    Join Date
    Oct 2006
    Posts
    25
    Quote Originally Posted by newcstudent
    ok. thanks man. i think i get it=) i really appreciate it... I hate being so elementary all of a sudden. i feel really annoying.
    Your welcome, and dont feel annoying, to be honest, im bored, so this helps "entertain" me

    If you still can't manage to get it to work come on back, and ill show you how to do it

  12. #12
    Registered User
    Join Date
    Oct 2006
    Posts
    38
    thanks. i'm sure i'll be back in like 5 minutes. maybe 10

  13. #13
    JDD
    JDD is offline
    Registered User
    Join Date
    Oct 2006
    Posts
    25
    Quote Originally Posted by newcstudent
    thanks. i'm sure i'll be back in like 5 minutes. maybe 10
    I'll be waiting, and don't feel discouraged, theres only one way to learn. Part of being a good programmer is being able to ask questions, and seek assistance from others who can give it, and theres nothing wrong with that.

  14. #14
    Registered User
    Join Date
    Oct 2006
    Posts
    38
    #include <stdio.h>

    {
    float r, n, a, p

    printf("what is the interest rate?\n");

    scanf("%f", &amount);

    return 0;
    }

    so far... is this anywhere near close?

    my assignment is excersize 2 at this url if you wanna check it for me.

    http://cs.clark.edu/~cowen/CSE121/As...ssignment.html

  15. #15
    Registered User
    Join Date
    Oct 2006
    Posts
    38
    hehe i forgot main (void)

Page 1 of 4 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. Replies: 8
    Last Post: 04-19-2006, 09:07 AM
  3. No clue what the problem is...
    By FingerPrint in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2006, 02:16 PM
  4. A really weird problem. I understand the error, but not a clue why I get the errors.
    By Finchie_88 in forum Networking/Device Communication
    Replies: 1
    Last Post: 02-20-2005, 08:48 AM
  5. No CLUE what to do...
    By stewade in forum C Programming
    Replies: 7
    Last Post: 05-03-2004, 12:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21