Thread: cant figure out where to start

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    25

    Question cant figure out where to start

    hi i have the "Starting out with C++" by Tony Gaddis 2nd Ed. and cant find the floppy is there a place u can download whats on it?..........my main problem is with chapter 3, page 151, Programing Challenge #13

    its shows this formula



    payment = Rate * (1+Rate)^n * L
    ((1+Rate)^n-1)



    and i am asked to make a program that asks for "n" , Rate, and "L" and displays a report simliar to this one
    Where; Rate = Interest rate, N=Number of payments, and L=Amount of the loan

    Loan Amount: $10000.00
    Monthly Interest Rate: 1%
    Number of Payments: 36
    Monthly Payment: $ 332.24
    Amount Paid back: $11957.00
    Interest Paid: $ 1957.00

    I cant figure out how to write the formula to get what it asks for? any ideas........i was thinking i use "POW"? but cant seem to find in my book anywhere if just gives the above example, since this is for class i dont want a complete answer......just alittle help figuring out how to use the formula.

    thanks

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    you'll have to use some sort of pow()

    its in math.h

    n to the power of 2 is
    pow(n,2);
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    25
    haha i feel stupid i think i got it tell me if u think there is a easier way to write this

    M =((Rate2 * pow(1+Rate2,N))/(pow(1+Rate2,N)-1))*L;

  4. #4
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    not that i can see.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    25
    okie here's a tuff one for ya.........i got it all made an it works great .........but how do i get all the numbers to line up
    EX.

    first day: 342
    second day: 234
    third day: 533

    something like that? i have tried all the SetIos flags i can think of an no change

  6. #6
    Registered User
    Join Date
    Aug 2001
    Posts
    154
    Originally posted by ii3ejoe
    haha i feel stupid i think i got it tell me if u think there is a easier way to write this

    M =((Rate2 * pow(1+Rate2,N))/(pow(1+Rate2,N)-1))*L;
    I don't know if it'd be easier, but you could set the elements of the formula to variables and then use the formula.
    double x = 1 + Rate2;
    double y = pow(x, N);
    double z = Rate2 * y;
    and so on, so the top half of the formula would be M = z/(same type of thing bottom half). This may not be easier, but might be clearer to read.

  7. #7
    Registered User
    Join Date
    Aug 2001
    Posts
    154
    Originally posted by ii3ejoe
    okie here's a tuff one for ya.........i got it all made an it works great .........but how do i get all the numbers to line up
    EX.

    first day: 342
    second day: 234
    third day: 533

    something like that? i have tried all the SetIos flags i can think of an no change
    Offhand, use setw(x) to cout the day followed by setw on the number. setw only works on the next value output. Something like:
    cout << setw(12) << "first day: " << setw(5) << num;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  2. C++ gui for windows where to start
    By prixone in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2006, 11:48 PM
  3. GNOME Desktop won't start (Mandriva)
    By psychopath in forum Tech Board
    Replies: 10
    Last Post: 07-19-2006, 01:21 PM
  4. WHEN to start game programming
    By mrcheesypants in forum Game Programming
    Replies: 18
    Last Post: 02-02-2006, 04:09 PM
  5. start another program
    By lshome in forum C Programming
    Replies: 3
    Last Post: 06-24-2002, 01:48 PM