jimblumberg's Profile User Rating: *****

Reputation: 4235 Guru
Group:
Mentors
Active Posts:
14,068 (7.82 per day)
Joined:
25-December 09
Profile Views:
69,579
Last Active:
User is online 37 minutes ago
Currently:
Viewing Board Index

Previous Fields

Country:
US
OS Preference:
Linux
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
50
Expert In:
C/C++

Latest Visitors

Icon   jimblumberg has not set their status

Posts I've Made

  1. In Topic: [ C/C++11 - win32 ] - can i send the class pointer with SetWindowHooke

    Posted 28 Nov 2014

    This is very related to your other topic, I suggest you use that prior topic. Closing this one.


    Jim
  2. In Topic: How is my code being followed by the compiler?

    Posted 28 Nov 2014

    This is C++ so I recommend you also look up and use references instead of pointers. But either way you may want to study the function tutorials contained in my signature. They should help explain the various methods used to pass values to functions, pass by value, pass by reference, and pass by pointer.


    Jim
  3. In Topic: Why can't I call this function?

    Posted 28 Nov 2014

    Quote

    Appreciate it, I've used x and y as global because anyway else, it just gave me a huge mess of problems.

    Like what? You need to define those variables in every function that requires them, and since this is C++ you could just define them in the for loops where they're being used.
    for(int x = 0; x < y; x++){
    


    Or:
    void InputData(string playerName[], double score[])
    {
       int x, y;
    
       cout << "Insert the number of players up to 100: ";
       cin >> y;
    


    Using global variables is a very very bad habit. You need to learn to properly declare and use the variables where they are needed.

    Quote

    I've spent way to long on this that I can't afford to do anything new.

    You really can't afford not to learn how to use variables properly. This one of the cornerstones to good programming.


    Jim
  4. In Topic: C- Amortization Table

    Posted 28 Nov 2014

    Quote

    Am a new user and don't want to paste my entire code

    That's fine as long as the code you provide actually illustrates the problem and shows enough content that we can actually see the problem. Many times it is better to show the smallest possible complete program so that the problem can be seen. For example with your code you could show just that function with a small main showing showing how you're calling the function. Insure the program provided illustrates the problem. By doing this you may find that you can actually spot the problem yourself because you have removed all the "complications" and have narrowed the problem scope to the smallest possible locations.

    // Show all the required headers 
    #include <iostream> 
    
    using namespace std;
    
    int myFunction(int value_to_print);
    
    int main()
    {
       myFunction(2000);
    
       return(0);
    }
    
    int myFunction(int value)
    {
       cout << value << endl;
    }
    


    But remember some problems require much more code. A segmentation fault for example could be caused by many factors and is quite often caused by something long before the actual location of the crash.

    Now to the problem.

    Quote

    I wanted to ask if I could get some help with the total amount paid because I've been trying different things and just can't get it to work. Here is the table function.

    After you have narrowed down the problem you need to ask specific questions. For example why isn't the total amount paid working? This is why showing exactly what you provided for the input (the parameters in this case) is important. You should also tell us what the program is outputting and what you expect the output to be with the input provided. This will help us locate the actual problem.

    On a quick glance I see something to look into, contained in the following snippet:
        double interest_paid;
        double principal_paid;
        double new_balance;
        double tot_payment;
    

    You have not initialized these variables so you need to check to see if you use any of them before you assign a value to them. You may want to start getting into the habit of initializing your variables when you declare them. If your results seem to be off by very large or very small amounts this is often an indication of using an uninitialized variable.

    Next when you're having problems with calculations you should make sure the calculations are being done on their own lines, and break apart complex calculations into separate variables on separate lines. This will help when you run the program through the debugger, since you can verify each part of he calculation. So instead of this:

    printf("\n\nTotal Amount Paid: %.2f", number_months * payment_monthly); //Output
    
    // For debugging the above calculation.
    double amount_paid = number_months * payment_monthly;
    printf("\n\nTotal Amount Paid: %.2f\n", amount_paid);
    printf("Number of months: %f\n", number_months);
    printf("Monthly payment: %f\n"), payment_monthly);
    
    


    Also I really don't recommend doing several calculations in your parameters to the output function. I usually only "print" the results of the formulas. This is because you can run into problems if one calculation modifies a value that is contained in calculation in another part of the print statement.

    Jim
  5. In Topic: Why can't I call this function?

    Posted 27 Nov 2014

    One of the first things I see wrong is this:
    void DisplayBelowAverage(string playerName[], double score[], double average);
    int x = 0; int y = 0;
    
    
    


    Why are x and y global variables? You seem to be using them for loop counters, so they should be local to the functions that need them.

    Next you have a couple of functions where you promised the compiler that you would return something, but you have failed to do so. Compilers don't like when you lie to them.

    Next you don't seem to know the difference between pass by value and pass by reference. You may want to study the function tutorials contained in my signature.

    Lastly but very important, you need to find an consistently use an indentation style you like. Your program as presented is very hard to read.


    Jim

My Information

Member Title:
Age:
Age Unknown
Birthday:
December 6
Gender:

Contact Information

E-mail:
Private

Comments

Page 1 of 1
  1. Photo

    modi123_1 Icon

    17 Nov 2014 - 08:11
    I like brocken's comment "I don't know much about coding, but it would be really easy".
    Heh.. I don't know anything about the topic, but I know it is easy.
    Riiiiiiiiiight.
  2. Photo

    brockenglass101 Icon

    22 Oct 2014 - 02:34
    I know that this isn't what this site is for but many people in the pc gaming comunity have been looking for screen magnification program that would zoom in on the center of the screan rather then the cursor (turned on and off with a hotkey). Now, I am not going to lie, I don't know much about coding, but it would be really easy to make program like this one.
    I hope you will find ...
  3. Photo

    KnifeTea Icon

    11 May 2014 - 05:55
    thanks for the help Jim!
  4. Photo

    tarmizi_adam2005 Icon

    04 Dec 2013 - 07:15
    Just stopping by to say Hello Jim. I've learned quite a few things from your posts in the c/c++ forum.
Page 1 of 1