Thread: ATM Program

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

    ATM Program

    Basically I'm having trouble getting started on my programming assignment because i've never used loops and pointers together so my brain is crying for help (I posted my project word file).

    We have to make an ATM system using loops and pointers.

    My teacher said we could complete this in like 2 days with only two pages of code, but I don't believe her >.>

    So if anyone could be my angel and assist me with this that would be just perfect.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Read this!!! Show work!
    Announcements - General Programming Boards

    Tim S.
    "...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
    Mar 2013
    Location
    West Palm Beach, Florida, United States
    Posts
    13
    Code:
    //This is my code so far. Now I just need help figuring out how to use the loops and pointers
    
    #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()
    {
        void mainMenu();
    }
    
    
    
    
    void mainMenu(int *option)
    {
        int choice;
        printf("1. Check Balance\n");
        printf("2. Withdraw Cash\n");
        printf("3. Deposit Cash\n");
        printf("4. Transer\n");
        printf("Enter your choice: ");
        scanf("%d",&choice);
    }
    
    
    
    
    void Keepgoing(char *goagain);
    
    
    
    
    void AccountMenu( char *acctType);
    
    
    
    
    void MakeDeposit( double *balance);
    
    
    
    
    void MakeWithdrawal( double *balance, char acctType);
    
    
    
    
    void GetBalance( double balance);

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    For, While and Do While Loops in C - Cprogramming.com

    Ask a specific question on a specific topic (in this case about a single function, might be good).

    I suggest the "Keepgoing" function is easy enough to start with.

    Try writing what you think should be in it.

    Tim S.
    "...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

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Untested re-write of your main and mainMenu functions.

    Tim S.

    Code:
    int main()
    {
        int choice;
        
        mainMenu(&choice);
    
        return 0;
    }
     
    void mainMenu(int *option)
    {
        printf("1. Check Balance\n");
        printf("2. Withdraw Cash\n");
        printf("3. Deposit Cash\n");
        printf("4. Transer\n");
        printf("Enter your choice: ");
        scanf("%d",option);
    }
    Last edited by stahta01; 03-13-2013 at 09:58 AM.
    "...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

  6. #6
    Registered User
    Join Date
    Mar 2013
    Location
    West Palm Beach, Florida, United States
    Posts
    13
    I'm pretty some sort of loop belongs here. Because after one thing is done it's
    going to want to know if you want to do something else or just quit.

    Code:
    void Keepgoing(char *goagain)
    {
    	printf("Would you like to do another transcation?");
    	printf("y/n?");
    	scanf(" %d", &goagain);
    }

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by rawr12 View Post
    I'm pretty some sort of loop belongs here. Because after one thing is done it's
    going to want to know if you want to do something else or just quit.

    Code:
    void Keepgoing(char *goagain)
    {
    	printf("Would you like to do another transcation?");
    	printf("y/n?");
    	scanf(" %d", &goagain);
    }
    And, other than global variables how are you going to tell the rest of the program any thing.

    Look at my updated code for mainMenu and look at this line of code of yours.
    Do you compile your code?
    Do you have warnings turned on?
    Do you know the mean of "%d" in scanf?
    If yes, what does it mean?

    Code:
    	scanf(" %d", &goagain);
    Tim S.
    Last edited by stahta01; 03-13-2013 at 12:34 PM. Reason: grammar
    "...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

  8. #8
    Registered User
    Join Date
    Mar 2013
    Location
    West Palm Beach, Florida, United States
    Posts
    13
    Okay I see now. It's because '&' and '*' basically cancel each other out.
    so it would be

    Code:
    scanf("%c", goagain);
    Last edited by rawr12; 03-13-2013 at 12:54 PM.

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by rawr12 View Post
    Okay I see now. It's because '&' and '*' basically cancel each other out.
    so it would be

    Code:
    scanf("%c", goagain);
    Good; but, you are likely to run into issues with that. See code below.
    The leading space before the %c tells scanf to skip over white space like new lines that are before the first non-white space character.

    Code:
    scanf(" %c", goagain);
    Tim S.
    "...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

  10. #10
    Registered User
    Join Date
    Mar 2013
    Location
    West Palm Beach, Florida, United States
    Posts
    13
    Ok this is what I have so far. I've compiled my code and the menu system ran perfectly.

    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);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-11-2012, 12:25 AM
  2. Replies: 1
    Last Post: 03-03-2009, 04:47 PM
  3. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  4. Replies: 5
    Last Post: 08-16-2007, 11:43 PM
  5. Replies: 18
    Last Post: 11-13-2006, 01:11 PM

Tags for this Thread