Thread: Seriously Stumped....

  1. #1
    Registered User
    Join Date
    Aug 2017
    Posts
    1

    Post Seriously Stumped....

    Hey everyone,

    Let me start off by saying that I'm in no way shape or form a coder (newb for sure). I don't have a bone in my body for it. I'm taking a Website creation and design course that for some reason put me in Programming with C as a mandatory class. The teacher doesn't even know why I'm in this class. Anyways, I'm stumped on an assignment. I am NOT looking for someone to do the work for me, but I am looking for pointers. I've been working on this assignment for nearly 2 weeks. I'm out of steam and about to give up.

    The basics of the code. My program is suppose to present a menu with options. This is a loan calculating program. Where I'm stumped is my math, I think I'm way off. And the table. I just can't get it. I finally manage to get the titles to appear where they are suppose to, but yeah....the rest of the program works. So, uhm here let's take a look-see. I've attached it as a file. Any pointers would be greatly appreciated!!
    Attached Files Attached Files

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Well, I overlooked the code and I believe you are close. You just need to study functions and return values some more. You have a habit of using return 0; when, say, returning the variable the user just entered would have been more helpful. You will also need to assign these return values to variables in main in order to use them across multiple functions. Importantly, count_d() and count_e().

    As for the math I think I can help you there. The formula I think you are trying to use, and that you should be using anyway, is the calculation for a monthly payment: c = Pr / (1 - (1 / (1 + r)n)). As for the interest, you just multiply c*r. It's important to remember that the rate is monthly interest, so in effect, divide the annual rate by 12 first.

    Then using the formulas to make the table might look like this, as a small example:
    Code:
    void plan (float bal, int yrTerm, float yrRate)
    {
        int month = 0, months = yrTerm * 12;
        float payment = 0;
        float interest = 0;
        printf("Month, Old Balance, Payment, Interest, New Balance\n");
        printf("---------------------------------------------------\n");
        for ( ; month < months; month++)
        {
            payment = MonthlyPayment(bal, yrRate / 12.0f, months - month);
            interest = yrRate / 12.0f * payment;
            printf("%d\t%.02f\t%.02f\t%.02f\t%.02f\n", month + 1, bal, payment, interest, bal + interest - payment);
            bal += interest;
            bal -= payment;
        }
    }
    
    Month, Old Balance, Payment, Interest, New Balance
    ---------------------------------------------------
    1       500.00  45.03   0.55    455.51
    2       455.51  44.49   0.54    411.56
    3       411.56  43.96   0.53    368.13
    4       368.13  43.43   0.53    325.23
    5       325.23  42.91   0.52    282.84
    6       282.84  42.40   0.52    240.96
    7       240.96  41.89   0.51    199.58
    8       199.58  41.39   0.50    158.70
    9       158.70  40.89   0.50    118.31
    10      118.31  40.40   0.49    78.40
    11      78.40   39.92   0.49    38.97
    12      38.97   39.44   0.48    0.01
    Beware of tiny accounting errors.

  3. #3
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stumped by this
    By Brolaf Broski in forum C Programming
    Replies: 6
    Last Post: 12-16-2013, 08:42 PM
  2. Stumped
    By mack99 in forum C Programming
    Replies: 6
    Last Post: 08-28-2012, 03:28 PM
  3. K&R 5.6, stumped again
    By The111 in forum C Programming
    Replies: 2
    Last Post: 08-17-2011, 08:43 PM
  4. stumped
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-10-2001, 01:27 PM
  5. I am stumped...
    By IGGY in forum C Programming
    Replies: 1
    Last Post: 10-06-2001, 11:15 PM

Tags for this Thread