Thread: Code Assistance

  1. #1
    Registered User
    Join Date
    Mar 2013
    Location
    West Palm Beach, Florida, United States
    Posts
    13

    Code Assistance

    Having a bit of trouble placing my loops in my program.
    I need to figure out how to show the balance of an account by entering the specific number next to the account.

    ex. In the voidmainMenu() when I to select a choice (Deposit) I want to select and make it connect to an account (Checking) and add money to it.

    Algorithm

    Display Bank Menu
    Get User Selection
    Deposit
    Account-Checking
    Add $500
    Do another transaction (Yes)
    Display Bank Menu
    Get User Selection
    Transfer
    Account-Credit
    Add $400 from Checking
    Do another transaction (Yes)
    Display Bank Menu
    Get User Selection
    Withdraw
    Account-Savings
    Take $200 from Savings
    Do another transcation (No)
    End.


    Code:
    #include <stdio.h>
    #include <math.h>
    #include <ctype.h>
    
    
    // Displays the list of options available
    //prompts for the user’s selection and sets the value of the selection
    void mainMenu(int *option);
    
    
    //Asks the user if they want another transaction
    void Keepgoing(char *goagain);
    
    
    //Asks the user which type of account they would like to access and sets the 
    //value of the selection
    void AccountMenu( char *acctType);
    
    
    //Prompts the user for the amount of deposit and updates the selected account 
    void MakeDeposit( double *balance);
    
    
    //Prompts the user for the amount of the withdrawal, determines if there are 
    //sufficient funds and updates the selected account if funds are dispensed 
    void MakeWithdrawal( double *balance, char acctType);
    
    
    //Displays the user’s current account balance for the selected account
    void GetBalance( double balance);
    
    
    int main()
    {
    	int choice;
    	char again,
    		account;
    
    
    	mainMenu(&choice);
    
    
    	AccountMenu(&account);
    
    
    	Keepgoing(&again);
    
    
    	return 0;
    }
    
    
    
    
    void mainMenu(int *option)
    {
    	printf("Welcome to Regional South Bank.\n\n");
    	printf("Please choose from the following.\n\n");
    	printf("1. Check Balance\n");
        printf("2. Withdraw Cash\n");
        printf("3. Deposit Cash\n");
        printf("4. Transfer\n");
        printf("\nEnter your choice:");
        scanf_s("%d",option);
    }
    
    
    
    
    void Keepgoing(char *goagain)
    {
    	printf("\nWould you like to do another transcation?\n");
    	printf("\nChoose y/n:");
    	scanf_s(" %c",goagain);
    }
    
    
    
    
    void AccountMenu(char *acctType)
    {
    	printf("\nWhich account would like to access?\n");
    	printf("\nC for Checking\n");
    	printf("\nS for Savings\n");
    	printf("\nE for Credit\n");
    	printf("\nChoose an account:");
    	scanf_s(" %c", acctType);
    }
    
    
    
    
    void MakeDeposit( double *balance);
    
    
    
    
    void MakeWithdrawal( double *balance, char acctType);
    
    
    
    
    void GetBalance( double balance);

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    I suggest a while do loop in your main function.

    For, While and Do While Loops in C - Cprogramming.com

    Edit: After adding loop to main, I would suggest GetBalance as the next likely function to try to write.
    MakeDeposit and MakeWithdrawal will be easier after you write and test GetBalance function.


    Tim S.

    PS: I am sorry for you; this assignment seems to be very stupid to me.
    I just read the assignment from your last thread.
    Last edited by stahta01; 03-14-2013 at 06:29 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    9
    I'm working on the same project. If you have a specific question I can help answer those. I'll be working (hopefully finishing) it tonight.
    As a disclaimer, I am not a coding wizard.

  4. #4
    Registered User
    Join Date
    Mar 2013
    Location
    West Palm Beach, Florida, United States
    Posts
    13
    How should I go about using a do while loop in the main function?

    Like i'm not sure how to start it off.

    I know that after I select an option from the menu it takes me to the account type,
    then from there it takes me to which account I want to use.

    I'm not sure where I should start the loop.

    Btw my teacher is really bad at explaining some of the things that goes on in class
    and tutors rarely can help because the assignment is just so retarded.

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    The loop should encompass those parts of the program that you want repeated. Like choosing the account type and further processing. So it should pretty much enclose all that.
    Code:
    do {
        mainMenu(&choice);
        AccountMenu(&account);
        Keepgoing(&again); 
        } while (again == 'y' || again == 'Y');
    The loop terminates when the user types anything other than 'y'. Such as 'n'.
    It's really a lot simpler than you think.

  6. #6
    Registered User
    Join Date
    Mar 2013
    Location
    West Palm Beach, Florida, United States
    Posts
    13
    Ok Now I need help with the adding and taking away from the account.
    I get the use of pointers already.
    But now does it come down to simply doing

    sum = the current balance in the account + money

    diff = the current balance - money


    • Checking - $850.00
    • Savings - $2500.00
    • Credit - $-1850.00


    Code:
    void MakeDeposit( double *balance);
    
    
    
    
    void MakeWithdrawal( double *balance, char acctType);
    
    
    
    
    void GetBalance(double balance);
    my new code


    Code:
    #include <stdio.h>
    #include <math.h>
    #include <ctype.h>
    
    
    // Displays the list of options available
    //prompts for the user’s selection and sets the value of the selection
    void mainMenu(int *option);
    
    
    //Asks the user if they want another transaction
    void Keepgoing(char *goagain);
    
    
    //Asks the user which type of account they would like to access and sets the 
    //value of the selection
    void AccountMenu( char *acctType);
    
    
    //Prompts the user for the amount of deposit and updates the selected account 
    void MakeDeposit( double *balance);
    
    
    //Prompts the user for the amount of the withdrawal, determines if there are 
    //sufficient funds and updates the selected account if funds are dispensed 
    void MakeWithdrawal( double *balance, char acctType);
    
    
    //Displays the user’s current account balance for the selected account
    void GetBalance( double balance);
    
    
    int main()
    {
    	int choice;
    
    
    	char again,
    		account;
    
    
    	double balance;
    
    
    do{
    	mainMenu(&choice);
    
    
    	printf("\nChoice entered was %d.\n", choice);
    
    
    	AccountMenu(&account);
    
    
    	printf("\nAccount type selected was %c.\n", account);
    
    
    	Keepgoing(&again);
    
    
    } while (again == 'y' || again == 'Y');
    
    
    if(again == 'n')
    {
    	printf("\nThank you. Have a nice day.\n\n",again);
    }
    
    
    	return 0;
    }
    
    
    
    
    void mainMenu(int *option)
    {
    	printf("Welcome to Regional South Bank.\n\n");
    	printf("Please choose from the following.\n\n");
    	printf("1. Check Balance\n");
        printf("2. Withdraw Cash\n");
        printf("3. Deposit Cash\n");
        printf("4. Transfer\n");
        printf("\nEnter your choice:");
        scanf_s("%d",option);
    }
    
    
    
    
    void Keepgoing(char *goagain)
    {
    	printf("\nWould you like to do another transcation?\n");
    	printf("\nChoose y/n:");
    	scanf_s(" %c",goagain);
    }
    
    
    
    
    void AccountMenu(char *acctType)
    {
    	printf("\nWhich account would like to access?\n");
    	printf("\nC for Checking\n");
    	printf("\nS for Savings\n");
    	printf("\nE for Credit\n");
    	printf("\nChoose an account:");
    	scanf_s(" %c", acctType);
    }
    
    
    
    
    void MakeDeposit( double *balance);
    
    
    
    
    void MakeWithdrawal( double *balance, char acctType);
    
    
    
    
    void GetBalance(double balance);

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    On line 56 or so above, you need to have either a switch() statement, or several if() else if() statements to call the right functions. MakeDeposit, etc., will need to have the type of account passed to them, so they can make the right account receive the deposit, or withdrawal, or get the balance from. MakeWithdrawal has the accType, but MakeDeposit needs it still.

    I like using a switch statement for this.

    AND YOU have a great style of coding.

    This is an example of it, using a video program (it's all in the menu() function, but the logic is the same for you).

    Code:
    void menu(void) {
       char ch;
       char buff[80];
       int i,n, index, ok=0;
      
       do {
          //clear the menu area of the display
          _gotoxy(1,1);
          //for(i=0;i<3;i++) {
          //printf("                                                                              *\n"); 
          //}
          printf("                                                                               \n");  
          _gotoxy(1,2);
          printf("                <<<<      Welcome to the Main Menu       >>>>                  \n");
          printf("                                                                               \n"); 
          printf("        [a] Add a video            [d] Delete a video                          \n");
          printf("        [e] Edit a video record    [s] Search for a video                      \n");
          printf("        [v] View all videos        [w] Write out all videos                    \n");
          printf("                                                                              *\n");
          printf("                     Your Choice, or Q to quit:                                \n");
          printf("                                                                              *\n"); 
          //i=_wherey();
          _gotoxy(49,8);    //row 8 is the Choice row in the menu
          fgets(buff, sizeof(buff), stdin);
          sscanf(&buff[0],"%c",&ch);
    
         //the switch example begins here  *******************
          switch (ch) {
             case 'a':   
                printf("\n Would you like to add a new video? [y/n]: ");
                ch = getchar();
                getchar();
                if(ch=='y' || ch=='Y') {
                   n=addVideos();
                   if(n) {   //a successful add
                      sortRecords();
                      _gotoxy(1,12);
                      printf(" One Video has been added. %d Videos in all now.                    **\n",NumVideos);
                      getchar(); 
                   }
                }
                _gotoxy(1,12);
               printf("                                                                              *\n"); 
                break;
             case 'd':  break;
                ok=idelete(); 
                if(ok)
                   --NumVideos;
                break;
          case 'e': edit();  
                    break;    
          case 's':  
             for(i=0;i<10;i++) {
                printf("                                                                              *\n"); 
             }
             _gotoxy(1,10);   
             printf("Enter the video's  \n  title: ");
             fgets(buff, sizeof(videos[0]), stdin); 
             buff[strlen(buff)-1]='\0';
             index = fetch(buff);
             //printf("Index: %d\n",index); getchar();
             if(index>-1) {
                printf(" #%d) title: %s\n  actors: %s\n   genra: %s\n  rating: %d\n\n",
                        index+1,videos[index].title,videos[index].actor,videos[index].genra,videos[index].rating);
                printf("                                                                              *\n"); 
                printf("                                                                              *\n"); 
                printf("                                                                              *\n"); 
                printf("                                                                              *\n"); 
                getchar();
             }
             break;
          case 'v':  view(); break;
          case 'w':  writeAll(); break;
    
          case 'Q':  ch='q';
          case 'q':  break;
          default: printf("\n\t\t    Please enter a valid selection\n");
        };
    
      }while(ch!='q'); 
    }

  8. #8
    Registered User
    Join Date
    Mar 2013
    Location
    West Palm Beach, Florida, United States
    Posts
    13
    Wow that's a lot to take in.

    But okay I get the gist of it.

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    It has some busy code in there - to make the display "just so", (for showing multiple records, etc.).

    The gist is that, in your do while() loop, you need to have a switch() statement (or several if else statements), to direct the calling of the appropriate functions, based on the users choice in the menu.

  10. #10
    Registered User
    Join Date
    Mar 2013
    Location
    West Palm Beach, Florida, United States
    Posts
    13
    I added some of the if statements.

    I think I entered in correctly.

    When I run the code it lets me pick from the main menu then the account type,

    I can do Deposit, but I can't do Balance or Withdraw.

    Code:
    #include <stdio.h>
    #include <math.h>
    #include <ctype.h>
    
    
    #define _CRT_SECURE_NO_WARNINGS
    
    
    
    
    // Displays the list of options available
    //prompts for the user’s selection and sets the value of the selection
    void mainMenu(int *option);
    
    
    //Asks the user if they want another transaction
    void Keepgoing(char *goagain);
    
    
    //Asks the user which type of account they _CRT_SECURE_NO_WARNINGS would like to access and sets the 
    //value of the selection
    void AccountMenu( char *acctType);
    
    
    //Prompts the user for the amount of deposit and updates the selected account 
    void MakeDeposit( double *balance);
    
    
    //Prompts the user for the amount of the withdrawal, determines if there are 
    //sufficient funds and updates the selected account if funds are dispensed 
    void MakeWithdrawal( double *balance, char acctType);
    
    
    //Displays the user’s current account balance for the selected account
    void GetBalance( double balance);
    
    
    int main()
    {
    	int choice,
    		acctType;
    
    
    	char again,
    		account;
    
    
    	double deposit, 
    		balance;
    
    
    do{
    	mainMenu(&choice);
    
    
    	printf("\nChoice entered was %d.\n", choice);
    
    
    	AccountMenu(&account);
    
    
    	printf("\nAccount type selected was %c.\n", account);
    		
    	if (choice == 1)
    	{
    		GetBalance(balance);
    	}
    
    
    	if (choice == 2)
    	{
    		MakeWithdrawal(&balance, acctType);
    	}
    
    
    	if (choice == 3)
    	{
    		MakeDeposit(&deposit);
    	}
    
    
    
    
    	Keepgoing(&again);
    
    
    } while (again == 'y' || again == 'Y');
    
    
    if(again == 'n')
    {
    	printf("\nThank you. Have a nice day.\n\n",again);
    }
    
    
    	return 0;
    }
    
    
    
    
    void mainMenu(int *option)
    {
    	printf("Welcome to Regional South Bank.\n\n");
    	printf("Please choose from the following.\n\n");
    	printf("1. Check Balance\n");
        printf("2. Withdraw Cash\n");
        printf("3. Deposit Cash\n");
        printf("\nEnter your choice:");
        scanf_s("%d",option);
    }
    
    
    
    
    void Keepgoing(char *goagain)
    {
    	printf("\nWould you like to do another transcation?\n");
    	printf("\nChoose y/n:");
    	scanf_s(" %c",goagain);
    }
    
    
    
    
    void AccountMenu(char *acctType)
    {
    	printf("\nWhich account would like to access?\n");
    	printf("\nC for Checking\n");
    	printf("\nS for Savings\n");
    	printf("\nE for Credit\n");
    	printf("\nChoose an account:");
    	scanf_s(" %c", acctType);
    }
    
    
    
    
    void MakeDeposit(double *balance)
    {
    	printf("How much would you like add:");
    	scanf_s(" %f", balance);
    }
    
    
    
    
    void MakeWithdrawal( double *balance, char acctType)
    {
    	printf("How much would you like to withdraw:");
    	scanf_s(" %f", balance);
    }
    
    
    
    
    void GetBalance(double balance)
    {
    	printf("\nThe balance is %d.");
    }

  11. #11
    Registered User
    Join Date
    Feb 2013
    Posts
    9
    When scanning a value I used %lf (%d scans ints not doubles, beware) for printf I recommened %.2lf so it doesn't display ton zeros, just the 10s and 1s place.

    Have you tested to make sure when you deposit money, the value updates? If not, make a printf statement after one of you deposits that displays the affected account to check to make sure.
    The functions are void so the don't return values so using the pointer to save the value and update. (Do this is your withdraw and deposit) from the looks of the code i dont think you have it to take the deposit and put it into a desired account, (not a big deal, in time)

    If you are worried about the user char input not being the proper case you could convert it to top upper case or lower (tolower) you can used
    Code:
    *acctType = toupper(*acctType);
    or just write the
    Code:
    again == 'y'|| again == 'Y'
    thats fine too.

    Getbalance if fine.
    So is AccountMenu and mainMenu
    you could add else statements to your ifs just in case of an incorrect input by the tester. (just to be a little dummy proof)



    *****************Spoiler**********************
    If you really trying to strike it on your own with only the occasional ask for help, ignore this.
    For the deposit and withdraw I created a new double inside the function definition to hold the scan value, the made it equal to the pointer.
    Code:
    void MakeDeposit(double *balance)
    {
        double  dpst = 0;
        scanf("%lf",&dpst);
        *balance = dpst;
    }
    ********************End******************

  12. #12
    Registered User
    Join Date
    Mar 2013
    Location
    West Palm Beach, Florida, United States
    Posts
    13
    I've added the variable that holds the current balance at the moment.
    I tried updating it using the MakeDeposit but I just ended up getting and error like usual.
    Also I keep getting another from MakeWithdrawal(double *balance, char acctType)

    Code:
    #include <stdio.h>
    #include <math.h>
    #include <ctype.h>
    
    
    #define _CRT_SECURE_NO_WARNINGS
    
    
    
    
    // Displays the list of options available
    //prompts for the user’s selection and sets the value of the selection
    void mainMenu(int *option);
    
    
    //Asks the user if they want another transaction
    void Keepgoing(char *goagain);
    
    
    //Asks the user which type of account they _CRT_SECURE_NO_WARNINGS would like to access and sets the 
    //value of the selection
    void AccountMenu( char *acctType);
    
    
    //Prompts the user for the amount of deposit and updates the selected account 
    void MakeDeposit( double *balance);
    
    
    //Prompts the user for the amount of the withdrawal, determines if there are 
    //sufficient funds and updates the selected account if funds are dispensed 
    void MakeWithdrawal( double *balance, char acctType);
    
    
    //Displays the user’s current account balance for the selected account
    void GetBalance( double balance);
    
    
    int main()
    {
    	int choice,
    		acctType;
    
    
    	char again,
    		account;
    
    
    	double deposit, 
    		balance,
    		checking=850.00,
    		savings=2500.00,
    		credit=-1850.00;
    
    
    do{
    	mainMenu(&choice);
    
    
    	printf("\nChoice entered was %d.\n", choice);
    
    
    	AccountMenu(&account);
    
    
    	printf("\nAccount type selected was %c.\n", account);
    		
    	if (choice == 1)
    	{
    		GetBalance(balance);
    	}
    
    
    	if (choice == 2)
    	{
    		MakeWithdrawal(&balance, acctType);
    	}
    
    
    	if (choice == 3)
    	{
    		MakeDeposit(&deposit);
    	}
    
    
    	Keepgoing(&again);
    
    
    } while (again == 'y' || again == 'Y');
    
    
    if(again == 'n')
    {
    	printf("\nThank you. Have a nice day.\n\n",again);
    }
    
    
    	return 0;
    }
    
    
    
    
    void mainMenu(int *option)
    {
    	printf("Welcome to Regional South Bank.\n\n");
    	printf("Please choose from the following.\n\n");
    	printf("1. Check Balance\n");
        printf("2. Withdraw Cash\n");
        printf("3. Deposit Cash\n");
        printf("\nEnter your choice:");
        scanf_s("%d",option);
    }
    
    
    
    
    void Keepgoing(char *goagain)
    {
    	printf("\nWould you like to do another transcation?\n");
    	printf("\nChoose y/n:");
    	scanf_s(" %c",goagain);
    }
    
    
    
    
    void AccountMenu(char *acctType)
    {
    	printf("\nWhich account would like to access?\n");
    	printf("\nC for Checking\n");
    	printf("\nS for Savings\n");
    	printf("\nE for Credit\n");
    	printf("\nChoose an account:");
    	scanf_s(" %c", acctType);
    }
    
    
    
    
    void MakeDeposit(double *balance)
    {
    	printf("\nHow much would you like add:");
    	scanf_s(" %f", balance);
    }
    
    
    
    
    void MakeWithdrawal( double *balance, char acctType)
    {
    	printf("\nHow much would you like to withdraw:");
    	scanf_s(" %lf", balance);
    }
    
    
    
    
    void GetBalance(double balance)
    {
    	printf("\nThe balance is %.2lf.", balance);
    }

  13. #13
    Registered User
    Join Date
    Feb 2013
    Posts
    9
    Code:
    #include <stdio.h>
    #include <math.h>
    #include <ctype.h>
    
    
    #define _CRT_SECURE_NO_WARNINGS
    
    
    
    // Displays the list of options available
    //prompts for the user’s selection and sets the value of the selection
    void mainMenu(int *option);
    
    
    //Asks the user if they want another transaction
    void Keepgoing(char *goagain);
    
    
    //Asks the user which type of account they _CRT_SECURE_NO_WARNINGS would like to access and sets the 
    //value of the selection
    void AccountMenu( char *acctType);
    
    
    //Prompts the user for the amount of deposit and updates the selected account 
    void MakeDeposit( double *balance);
    
    
    //Prompts the user for the amount of the withdrawal, determines if there are 
    //sufficient funds and updates the selected account if funds are dispensed 
    void MakeWithdrawal( double *balance, char acctType);
    
    
    //Displays the user’s current account balance for the selected account
    void GetBalance( double balance);
    
    
    int main()
    {
        int choice,
            acctType;
    
    
        char again,
            account;
    
    
        double deposit, 
            balance,
            checking=850.00,
            savings=2500.00,
            credit=-1850.00;
    
    
    do{
        mainMenu(&choice);
    
    
        printf("\nChoice entered was %d.\n", choice);
    
    
        AccountMenu(&account);
    
    
        printf("\nAccount type selected was %c.\n", account);
    /*On your code, everything above this comment is fine.
    	The if statements below are fine , another option is Switch Case statements.
    	No matter what order of IF or CASE statements you use, you need a If or Case for the mainMenu, 
    	and another If or Case INSIDE the statements for the AccountMenu
    	
    	Example:
    	if (choice == 1)
        {
            if (account == 'c' || account == 'C')
    		GetBalance(checking);
        }
    	
    	So inside each of the first IFs (1,2,3) put in secondary IFs (C,S,E)
    	*/
    
    
        if (choice == 1)
        {
            GetBalance(balance);
    /*
    		balance is strictly a place holder used by the function definitions to pass values back to main, it wont give you the true value.
    		Instead of GetBalance(balance) do GetBalance(checking), GetBalance(savings), or GetBalance(credit) 
    		depending what the user wants to see the value of.
    		*/
        }
    
    
        if (choice == 2)
        {
            MakeWithdrawal(&balance, acctType);
        }
    
    
        if (choice == 3)
        {
            MakeDeposit(&deposit);
        }
    /*
         Stricly a recommendation.
    
         else 
         {
    	printf("Your entry was not recognized");
          }
    	*/
    
        Keepgoing(&again);
    
    } while (again == 'y' || again == 'Y');
    
    
    if(again == 'n')
    {
        printf("\nThank you. Have a nice day.\n\n",again);
    }
    
    
        return 0;
    }
    
    
    
    
    void mainMenu(int *option)
    {
        printf("Welcome to Regional South Bank.\n\n");
        printf("Please choose from the following.\n\n");
        printf("1. Check Balance\n");
        printf("2. Withdraw Cash\n");
        printf("3. Deposit Cash\n");
        printf("\nEnter your choice:");
        scanf_s("%d",option);
    }
    
    
    
    
    void Keepgoing(char *goagain)
    {
        printf("\nWould you like to do another transcation?\n");
        printf("\nChoose y/n:");
        scanf_s(" %c",goagain);
    }
    
    
    
    
    void AccountMenu(char *acctType)
    {
        printf("\nWhich account would like to access?\n");
        printf("\nC for Checking\n");
        printf("\nS for Savings\n");
        printf("\nE for Credit\n");
        printf("\nChoose an account:");
        scanf_s(" %c", acctType);
    }
    
    
    
    
    void MakeDeposit(double *balance)
    {
        printf("\nHow much would you like add:");
        scanf_s(" %f", balance);
    }
    
    
    
    
    void MakeWithdrawal( double *balance, char acctType)
    {
        printf("\nHow much would you like to withdraw:");
        scanf_s(" %lf", balance);
    }
    
    
    
    
    void GetBalance(double balance)
    {
        printf("\nThe balance is %.2lf.", balance);
    }

  14. #14
    Registered User
    Join Date
    Mar 2013
    Location
    West Palm Beach, Florida, United States
    Posts
    13
    Okay this code worked perfectly. It displayed all the balances.
    I changed the variables for Checking, Savings, and Credit to C, S, and E.

    Code:
    if (choice == 1)
    	{
    		if (account == 'c' || account == 'C')
    			GetBalance(C);
    		if (account == 's' || account == 'S')
    			GetBalance(S);
    		if (account == 'e' || account == 'E')
    			GetBalance(E);
    	}
    Now I just need help udapting the values.

    Would do something like balance = checking + deposit ?

  15. #15
    Registered User
    Join Date
    Feb 2013
    Posts
    9
    balance = checking + deposit isn't the ideal solution


    checking = 850.00
    Deposit = 100

    950 = 850 + 100

    the math is right but the new balance is saved under the variable balance.
    so next time i go to check the value of checking, it will still say 850.00

    checking = checking + balance;

    this takes the old checking the deposited balance and updates it to checking.
    whenever it is reached for here after, it equals the correct value.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner code assistance
    By akust0m in forum C Programming
    Replies: 6
    Last Post: 08-07-2012, 09:29 PM
  2. C code, MD5 hash, if statements assistance
    By letmein in forum C Programming
    Replies: 5
    Last Post: 09-14-2010, 09:25 AM
  3. Hello,i need assistance in completing the code
    By toader in forum C++ Programming
    Replies: 1
    Last Post: 06-22-2009, 03:32 AM
  4. Code Assistance
    By Nezmin2 in forum C Programming
    Replies: 12
    Last Post: 12-19-2008, 12:26 AM
  5. C code assistance please
    By lotus in forum C Programming
    Replies: 7
    Last Post: 05-25-2002, 02:29 AM

Tags for this Thread