I am finishing up my atm program and have an issue with my program.  When I withdraw more than 300 it does not return an error message or show the amount withdrawed in my program.  I am not sure if this is related or not but the deposit and withdraw are the same variable so maybe there is a way to change this...here is the code that you might need followed by all the code if it helps

//Begin coding the program
#include <iostream>
#include <iomanip>
#include <time.h>
#include <fstream>
#include <conio.h>
#include <string>
 
using namespace std;

//Function prototypes
void showMenu();
int mainMenuSelection(int);
void welcomeScreen();
double enterAmountScreen(double);
int anotherTransactionScreen(int);
void goodbyeScreen();
void wait(int);
int dataEntryScreen();
void timeStamp();
void depositTest(double);

//void withdrawMax();

/*
******************************************************************
******************************************************************
** MAIN FUNCTION                                                 *
** int main function                                             *
******************************************************************
******************************************************************
*/

int main ()
{
    //Declare variables
    int choice;
   
    //Set the numeric output formatting
    cout << fixed << showpoint << setprecision(2);

    //Function for welcome screen
    welcomeScreen();

    //Give space for the function of date and time
    cout << endl << endl;

    //Prompt to show today's date
    cout << "Today's date is: " << endl;

    //Show date and time function
    timeStamp();

    //Enter some space
    cout << endl << endl;

    //Function to enter a pin number
    choice = dataEntryScreen();

    //if statement for choice
    if (choice == -1)

        //Return a value
        return 0;

    //Create a do\while loop
    do
    {
        //Display the menu and get the user's choice.
        showMenu();
        cin >> choice;

        //Validate the menu selection.
        while (choice < 1 || choice > 5)
        {
            //Prompt user to reenter a correct choice
            cout << "Please enter 1, 2, 3, 4, or 5: ";
            cin >> choice;

            //add color to error message
            //add color to error message
            system ("Color 3a");
        }
       
        //Function to choose in the main menu selection
        mainMenuSelection(choice);

    //End the while statement
    } while (choice != 5);
   
    //Function returns a value
    return 0;
}

int mainMenuSelection(int choice)
    {
        //Declare variables in mainMenuSelection
        int withdrawChoice,
            depositChoice,
            checkBalanceChoice,
            fundsTransferChoice;
        double money = 0.0;
       
        //Respond to user's menu selection
        switch (choice)
        {
        //switch case 1
        case 1:

            //Perform do\while loop to check for correct validation
            do
            {
                //let customer know he\she cannot withdraw more than 300 per day
                cout << endl << "You may not withdraw more than $300 for this date:" << endl << endl;

                //function to enter date and time
                timeStamp();

                //give some spaces from main menu
                cout << endl;

                //Show output of function
                cout << endl << "\t\tWithdrawal Screen" << endl << endl;
                cout << "1) From Checking" << endl;
                cout << "2) From Savings" << endl;
                cout << "3) Quick Cash" << endl;
                cout << "4) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> withdrawChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6a");

                //While statement to check validation
                while (withdrawChoice < 1 || withdrawChoice > 4)
                {
                    //Prompt user to reenter a correct number
                    cout << "Please reenter 1, 2, 3, 4: ";
                    cin >> withdrawChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }

                //Perform if statement
                if (withdrawChoice != 4)
                {
                    do
                    {
                    //Declare variables
                    int val = enterAmountScreen(money);
                   
                    while (money > 300)
                    {
                        cout << "An error has occurred!" << endl;
                        cout << "You have withdrawn more than the max allowed per day!" << endl;
                        cout << "Please enter a withdraw amount less than or equal to $300: ";
                        cin >> money;

                        //add color to error message
                        //add color to error message
                        system ("Color 3a");
                    }

                    cout << "You have withdrawn $" << withdrawmoney << endl;

                    //Perform another while statement
                    } while (money > 300);

                    //Return the value
                    return -1;
                }
            
            //Complete do\while statement
            } while (withdrawChoice != 4);
           
            //Back to main menu option
            if (withdrawChoice == 4)
            {
                //Return a value
                return -1;
            }

            //Perform a break to go to next case
            break;
       
        //Perform case 2
        case 2:

            //Perform do\while loop to check for correct validation
            do
            {
                //Display output of Deposit Screen
                cout << endl << "\t\tDeposit Screen" << endl << endl;
                cout << "1) To Checking" << endl;
                cout << "2) To Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> depositChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6b");
               
                //Check for validation
                while (depositChoice < 1 || depositChoice > 3)
                {
                    //Prompt user to enter a correct choice
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> depositChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }

                //Perform an if statment
                if (depositChoice !=3)
                {
                    //Declare value in function
                    int val = enterAmountScreen(money);
                }

            //end do\while loop
            } while (depositChoice != 3);

            //Back to main menu option
            if (depositChoice == 3)
            {
                //Return a value
                return -1;
            }

            //Perform a break to go to next case
            break;

        //Prompt to enter case 3
        case 3:

            //Perform do\while loop to check for correct validation
            do
            {
                //Display output
                cout << "\t\tCheck Balance Screen" << endl << endl;
                cout << "1) From Checking" << endl;
                cout << "2) From Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Enter enter a selection: ";
                cin >> checkBalanceChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6c");
               
                //Check for validation
                while (checkBalanceChoice < 1 || checkBalanceChoice > 3)
                {
                    //Check for validation
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> checkBalanceChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }

            //End while statement
            } while (checkBalanceChoice != 3);

            //Back to main menu option
            if (checkBalanceChoice ==3)
            {
                //Return a value
                return -1;
            }

            //Perform break to go to next case
            break;

        //Prompt to begin case 4
        case 4:

            //Perform do\while loop to check for correct validation
            do
            {
                //Display output
                cout << "\t\tFunds Transfer Screen" << endl << endl;
                cout << "1) From Savings to Checking" << endl;
                cout << "2) From Checking to Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> fundsTransferChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6d");

                //Check for validation
                while (fundsTransferChoice < 1 || fundsTransferChoice > 3)
                {
                    //Prompt user to enter correct selection
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> fundsTransferChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }
               
                //Perform if statement
                if (fundsTransferChoice != 3)
                {
                    //Declare values in function
                    int val = enterAmountScreen(money);

                    //Return a value
                    return -1;
                }

            //End do while loop
            } while (fundsTransferChoice != 3);

            //Back to main menu option
            if (choice == 3)
            {
                //Return a value
                return -1;
            }

            //Prompt to break to next case
            break;

        //Prompt to enter next case
        case 5:

            //End the program if 5 is selected
            cout << "Program ending." << endl << endl;

            //add color to background of withdraw screen
            //add color to text of main menu screen
            system ("Color 6e");

            //Perform break
            break;
        }

        //Returns a value
        return 0;
    }

double enterAmountScreen(double money)
{
    //Declare function variables
    int decision,
    anotherTransactionChoice = 0;
           
    //prompt user to begin do statemen
    do
    {
        //Show output of function
        cout << endl << "\t\tEnter Amount Screen" << endl;
        cout << "1) Enter an amount:";
        cout << endl << "2) Back to Main Menu:";
        cout << endl << "Please enter a selection: ";
        cin >> decision;

        //add color to background of enter amount screen
        //add color to text of enter amount screen
        system ("Color 1c");

        /*
        *******************************************
        * Return to main menu option              *
        * Create if statement for decision        *
        *******************************************
        */

        while (decision < 1 || decision > 2)
        {
            //Enter a correct number
            cout << "Please reenter 1 or 2: ";
            cin >> decision;

            //add color to error message
            //add color to error message
            system ("Color 3a");
        }

        if (decision == 2)
        {
            return -1;
        }

        //Perform next if statement
        if (decision == 1)
        {
            //Prompt user to enter the amount
            cout << "Please enter the amount: ";
            cin >> money;


            depositTest(money);
        }

        } while (decision < 1 || decision > 2);
   

        //Perform anotherTransactionScreen function
        anotherTransactionScreen(anotherTransactionChoice);

        //Create a space
        cout << endl;

        //Perform timeStamp function
        timeStamp();
   
    //Return a value
    return money;

}

void depositTest(double money)
{

    //if money is greater than 10000 if statement
    if (money > 10000)
    {
        //show an error message
        cout << endl << "This ATM has encountered one of the following errors...";
        cout << endl << "1. This atm has reached the total amount of deposits it can hold.";
        cout << endl << "2. There is not enough cash available to withdraw this amount.";
        cout << endl << "We apologize for this inconvenience.";
        cout << endl << "Please enter a smaller transaction.";
        cout << endl;

        //exit to prompt user to the enter another transaction screen
        exit;
    }
}


PLEASE LET ME KNOW IF THAT IS CONFUSING...BY THE WAY THIS IS ONLY IN CAPS SO IT STANDS OUT....

here is my code of the entire program if it helps any...

//Begin coding the program
#include <iostream>
#include <iomanip>
#include <time.h>
#include <fstream>
#include <conio.h>
#include <string>
 
using namespace std;

//Function prototypes
void showMenu();
int mainMenuSelection(int);
void welcomeScreen();
double enterAmountScreen(double);
int anotherTransactionScreen(int);
void goodbyeScreen();
void wait(int);
int dataEntryScreen();
void timeStamp();
void depositTest(double);

//void withdrawMax();

/*
******************************************************************
******************************************************************
** MAIN FUNCTION                                                 *
** int main function                                             *
******************************************************************
******************************************************************
*/

int main ()
{
    //Declare variables
    int choice;
   
    //Set the numeric output formatting
    cout << fixed << showpoint << setprecision(2);

    //Function for welcome screen
    welcomeScreen();

    //Give space for the function of date and time
    cout << endl << endl;

    //Prompt to show today's date
    cout << "Today's date is: " << endl;

    //Show date and time function
    timeStamp();

    //Enter some space
    cout << endl << endl;

    //Function to enter a pin number
    choice = dataEntryScreen();

    //if statement for choice
    if (choice == -1)

        //Return a value
        return 0;

    //Create a do\while loop
    do
    {
        //Display the menu and get the user's choice.
        showMenu();
        cin >> choice;

        //Validate the menu selection.
        while (choice < 1 || choice > 5)
        {
            //Prompt user to reenter a correct choice
            cout << "Please enter 1, 2, 3, 4, or 5: ";
            cin >> choice;

            //add color to error message
            //add color to error message
            system ("Color 3a");
        }
       
        //Function to choose in the main menu selection
        mainMenuSelection(choice);

    //End the while statement
    } while (choice != 5);
   
    //Function returns a value
    return 0;
}
 
/*
***********************************************************
***********************************************************
* Main Menu Function                                      *
* Function to show the main menu                          *
***********************************************************
***********************************************************
*/

void showMenu()
    {
        //Display the main menu screen
        cout << endl << "\t\tMain Menu Screen" << endl << endl;
        cout << "1) Withdrawal" << endl;
        cout << "2) Deposit" << endl;
        cout << "3) Check Balance" << endl;
        cout << "4) Funds Transfer" << endl;
        cout << "5) Exit ATM" << endl << endl;
        cout << "Please enter a selection: ";

        //add color to background of main menu screen
        //add color to text of main menu screen
        system ("Color 1a");
    }

/*   
*********************************************************************
*********************************************************************
* Main Menu Screen                                                  *
* Function to choose in the main menu screen                        *
*********************************************************************
*********************************************************************
*/

int mainMenuSelection(int choice)
    {
        //Declare variables in mainMenuSelection
        int withdrawChoice,
            depositChoice,
            checkBalanceChoice,
            fundsTransferChoice;
        double money = 0.0;
       
        //Respond to user's menu selection
        switch (choice)
        {
        //switch case 1
        case 1:

            //Perform do\while loop to check for correct validation
            do
            {
                //let customer know he\she cannot withdraw more than 300 per day
                cout << endl << "You may not withdraw more than $300 for this date:" << endl << endl;

                //function to enter date and time
                timeStamp();

                //give some spaces from main menu
                cout << endl;

                //Show output of function
                cout << endl << "\t\tWithdrawal Screen" << endl << endl;
                cout << "1) From Checking" << endl;
                cout << "2) From Savings" << endl;
                cout << "3) Quick Cash" << endl;
                cout << "4) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> withdrawChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6a");

                //While statement to check validation
                while (withdrawChoice < 1 || withdrawChoice > 4)
                {
                    //Prompt user to reenter a correct number
                    cout << "Please reenter 1, 2, 3, 4: ";
                    cin >> withdrawChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }

                //Perform if statement
                if (withdrawChoice != 4)
                {
                    do
                    {
                    //Declare variables
                    int val = enterAmountScreen(money);
                   
                    while (money > 300)
                    {
                        cout << "An error has occurred!" << endl;
                        cout << "You have withdrawn more than the max allowed per day!" << endl;
                        cout << "Please enter a withdraw amount less than or equal to $300: ";
                        cin >> money;

                        //add color to error message
                        //add color to error message
                        system ("Color 3a");
                    }

                    cout << "You have withdrawn $" << withdrawmoney << endl;

                    //Perform another while statement
                    } while (money > 300);

                    //Return the value
                    return -1;
                }
            
            //Complete do\while statement
            } while (withdrawChoice != 4);
           
            //Back to main menu option
            if (withdrawChoice == 4)
            {
                //Return a value
                return -1;
            }

            //Perform a break to go to next case
            break;
       
        //Perform case 2
        case 2:

            //Perform do\while loop to check for correct validation
            do
            {
                //Display output of Deposit Screen
                cout << endl << "\t\tDeposit Screen" << endl << endl;
                cout << "1) To Checking" << endl;
                cout << "2) To Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> depositChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6b");
               
                //Check for validation
                while (depositChoice < 1 || depositChoice > 3)
                {
                    //Prompt user to enter a correct choice
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> depositChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }

                //Perform an if statment
                if (depositChoice !=3)
                {
                    //Declare value in function
                    int val = enterAmountScreen(money);
                }

            //end do\while loop
            } while (depositChoice != 3);

            //Back to main menu option
            if (depositChoice == 3)
            {
                //Return a value
                return -1;
            }

            //Perform a break to go to next case
            break;

        //Prompt to enter case 3
        case 3:

            //Perform do\while loop to check for correct validation
            do
            {
                //Display output
                cout << "\t\tCheck Balance Screen" << endl << endl;
                cout << "1) From Checking" << endl;
                cout << "2) From Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Enter enter a selection: ";
                cin >> checkBalanceChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6c");
               
                //Check for validation
                while (checkBalanceChoice < 1 || checkBalanceChoice > 3)
                {
                    //Check for validation
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> checkBalanceChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }

            //End while statement
            } while (checkBalanceChoice != 3);

            //Back to main menu option
            if (checkBalanceChoice ==3)
            {
                //Return a value
                return -1;
            }

            //Perform break to go to next case
            break;

        //Prompt to begin case 4
        case 4:

            //Perform do\while loop to check for correct validation
            do
            {
                //Display output
                cout << "\t\tFunds Transfer Screen" << endl << endl;
                cout << "1) From Savings to Checking" << endl;
                cout << "2) From Checking to Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> fundsTransferChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6d");

                //Check for validation
                while (fundsTransferChoice < 1 || fundsTransferChoice > 3)
                {
                    //Prompt user to enter correct selection
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> fundsTransferChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }
               
                //Perform if statement
                if (fundsTransferChoice != 3)
                {
                    //Declare values in function
                    int val = enterAmountScreen(money);

                    //Return a value
                    return -1;
                }

            //End do while loop
            } while (fundsTransferChoice != 3);

            //Back to main menu option
            if (choice == 3)
            {
                //Return a value
                return -1;
            }

            //Prompt to break to next case
            break;

        //Prompt to enter next case
        case 5:

            //End the program if 5 is selected
            cout << "Program ending." << endl << endl;

            //add color to background of withdraw screen
            //add color to text of main menu screen
            system ("Color 6e");

            //Perform break
            break;
        }

        //Returns a value
        return 0;
    }

/*
**********************************************************
**********************************************************
* Welcome Screen                                         *
* Function to display the welcome screen                 *
**********************************************************
**********************************************************
*/
void welcomeScreen()
        {
            //Show output of function
            cout << "Hit enter to simulate inserting card";
            //Hit enter to go to the next screen
            cin.get();

        //add color to background of main menu screen
        //add color to text of main menu screen
        system ("Color 1b");
        }

/*
**********************************************************
**********************************************************
* Enter amount screen                                    *
* Function to enter amount screen                        *
**********************************************************
**********************************************************
*/
double enterAmountScreen(double money)
{
    //Declare function variables
    int decision,
    anotherTransactionChoice = 0;
           
    //prompt user to begin do statemen
    do
    {
        //Show output of function
        cout << endl << "\t\tEnter Amount Screen" << endl;
        cout << "1) Enter an amount:";
        cout << endl << "2) Back to Main Menu:";
        cout << endl << "Please enter a selection: ";
        cin >> decision;

        //add color to background of enter amount screen
        //add color to text of enter amount screen
        system ("Color 1c");

        /*
        *******************************************
        * Return to main menu option              *
        * Create if statement for decision        *
        *******************************************
        */

        while (decision < 1 || decision > 2)
        {
            //Enter a correct number
            cout << "Please reenter 1 or 2: ";
            cin >> decision;

            //add color to error message
            //add color to error message
            system ("Color 3a");
        }

        if (decision == 2)
        {
            return -1;
        }

        //Perform next if statement
        if (decision == 1)
        {
            //Prompt user to enter the amount
            cout << "Please enter the amount: ";
            cin >> money;


            depositTest(money);
        }

        } while (decision < 1 || decision > 2);
   

        //Perform anotherTransactionScreen function
        anotherTransactionScreen(anotherTransactionChoice);

        //Create a space
        cout << endl;

        //Perform timeStamp function
        timeStamp();
   
    //Return a value
    return money;

}

/*
***********************************************************************
***********************************************************************
* Another Transaction Screen                                          *
* Function to enter another transaction screen                        *
***********************************************************************
***********************************************************************
*/

int anotherTransactionScreen(int anotherTransactionChoice)
{
    //Perform a do statement
    do
    {
        //Display output
        cout << endl << "\t\tAnother Transaction Screen" << endl;
        cout << "1.) Enter another transaction" << endl;
        cout << "2.) Exit the ATM ";
        cout << endl << "Please enter a selection: ";
        cin >> anotherTransactionChoice;

        //add color to background of another transaction screen
        //add color to text of another transaction screen
        system ("Color 1d");
       
        /*
        ********************************************************************
        ********************************************************************
        * Check for validation                                             *
        * Use while statement                                              *
        ********************************************************************
        ********************************************************************
        */
       
        //Perform while statement
        while (anotherTransactionChoice < 1 || anotherTransactionChoice > 2)
        {
            //Enter a correct number
            cout << "Please reenter 1 or 2: ";
            cin >> anotherTransactionChoice;

            //add color to error message
            //add color to error message
            system ("Color 3a");
        }

        //If statement to return to main menu
        if (anotherTransactionChoice == 1)
        {
            //Return a value
            return -1;
        }
       
        //If statement to display the goodbye screen and exit
        if (anotherTransactionChoice == 2)
        {
            //Go to goodbye function
            goodbyeScreen();

            //Return a value
            return 1;
        }
   
    //end do\while statement
    } while (anotherTransactionChoice == 2 || anotherTransactionChoice == 1);

    //Return a value
    return anotherTransactionChoice;
}

/*
***************************************************************
***************************************************************
* Goodbye Screen                                              *
* Function to display goodbye Screen                          *
***************************************************************
***************************************************************
*/

void goodbyeScreen()
{
    //Declare variables in goodbye screen
    int seconds = 10;

    //Display a goodbye message
    cout << endl << endl << "Have a nice day!" << endl << endl;
    wait(seconds);

    //add color to background of goodbye screen
    //add color to text of googbye screen
        system ("Color 1f");
}

/*
*****************************************************************
*****************************************************************
* Wait function                                                 *
* Function to wait 10 seconds before returning to main menu     *
*****************************************************************
*****************************************************************
*/

void wait(int seconds)
{
    //Declare variables
    clock_t endwait;

    //Calculate seconds
    endwait = clock () + seconds * CLK_TCK ;

    //Perform while statement for seconds
    while (clock() < endwait) {}
}


/*
***********************************************************
***********************************************************
* Enter pin                                               *
* Function to enter a pin number                          *
***********************************************************
***********************************************************
*/

int dataEntryScreen()
{
    //Declare variables
    string valid,
           pin;
    bool found = false;
    int pinChoice,
        i,
        j = 3;
    ifstream Input;

    //Perform do\while loop to check for correct validation
    do
    {
        //Display the output
        cout << "\t\tData Entry Screen";
        cout << endl << "1) Enter pin number";
        cout << endl << "2) Exit the ATM";
        cout << endl << "Please enter a selection: ";
        cin >> pinChoice;

        //add color to background of data entry screen
        //add color to text of data entry screen
        system ("Color 3c");

        /*
        **********************************************
        **********************************************
        * Check for validation                       *
        * Use while statement                        *
        **********************************************
        **********************************************
        */

        //Perform while statement
        while (pinChoice < 1 || pinChoice > 2)
        {
            //Enter a correct choice
            cout << "Please reenter 1 or 2: ";
            cin >> pinChoice;

            //add color to error message
            //add color to error message
            system ("Color 3a");
        }

        //If statement if 2 is selected
        if (pinChoice == 2)
        {
            //exit the atm and returning a value
            return -1;
        }

    //end do\while loop
    } while (pinChoice > 2 || pinChoice < 1);

    /*
    *******************************************
    *******************************************
    * If statement 1 is selected              *
    * Perform for loop                        *
    *******************************************
    *******************************************
    */

    for (j = 0; j < 3; j++)
    {
        //Prompt user to enter pin number
        cout << "Please enter your 4 character pin number ";
        cin >> pin;
       
    //Open the file
    Input.open("pin.txt"); 
   
    //Perform error test
    if(Input.fail( ))
    {
        //Display error opening file.
        cout << endl << "Error opening input file" << endl;

        //add color to error message
        //add color to error message
        system ("Color 3a");
    }

    //Determine if false
    found = false;

    //Input valid
    Input >> valid;

    //Perform while statement
    while (Input && !found)
    {
        //Perform for loop
        for (i = 0; i < 5; i++)
        {
            //if statement for pin
             if (pin[i] != valid[i])
            i = 6;
        }

        //Determine if true with if statement
        if (i == 5)
            found = true;

        //Perform else statement
        else
            Input >> valid;
    }
   
    //Skip a line
    cout << endl;

    //Close the file
    Input.close();

    //Clear the file
    Input.clear();

    //If statement if pin number found
    if (found)

        //Return a value
        return 0;

    //Allow only 3 chances for pin to be valid
    if (j < 2)

    //Output for invalid pin number
    cout << endl << "Invalid pin";
    cout << endl << "You have " << 2-j << " more tries" << endl << endl;

    //add color to error message
    //add color to error message
    system ("Color 3a");
}

    //If statement if pin number is wrong three times
    if (!found)
    {
        //Display output of wrong pin three times
        cout << endl << "Invalid pin";
        cout << endl << "System aborting";
        cout << endl << "Your account has been locked" << endl;

        //Add a pause to the program
        system("pause");

        //add color to error message
        //add color to error message
        system ("Color 3a");

        //Return a value
        return -1;
    }
}   

/*
********************************************************************
********************************************************************
* Enter timestamp                                                  *
* Function to enter timestamp                                      *
********************************************************************
********************************************************************
*/

void timeStamp()
{
    //Calendar time
     time_t ltime;

     //Get current cal time
     ltime=time(NULL);

     //Prints out the results
     printf("%s",asctime( localtime(&ltime) ) );
}

/*
*********************************************************
* Withdraw Max                                          *
* Function to place a limit on                          *
* drawing the max cash                                  *
*********************************************************
*/

//double withdrawMax(double money)
//{
   
//

/*
***********************************************************
* Deposit Test                                            *
* Function to determine if atm has room                   *
* to make a deposit                                       *
***********************************************************
*/

void depositTest(double money)
{

    //if money is greater than 10000 if statement
    if (money > 10000)
    {
        //show an error message
        cout << endl << "This ATM has encountered one of the following errors...";
        cout << endl << "1. This atm has reached the total amount of deposits it can hold.";
        cout << endl << "2. There is not enough cash available to withdraw this amount.";
        cout << endl << "We apologize for this inconvenience.";
        cout << endl << "Please enter a smaller transaction.";
        cout << endl;

        //exit to prompt user to the enter another transaction screen
        exit;
    }
}

Recommended Answers

All 27 Replies

You had another thread recently on a very similar topic that I responded to and you never responded back.

http://www.daniweb.com/forums/thread262999.html

I don't know if this is the same problem or not.

If you post 1200+ lines, you should point us in the right direction. A few things stand out:

Line 158 - What does val represent? It isn't used.
Lines 158 and 170 - What do money and withdrawmoney represent? You ask how much they want to withdraw and store it in money, not withdrawmoney, or you store it in val, or something. Not sure. If you're storing it in val, you never use val.
Line 173 - It's the same test as line 158. I can't see how the outer loop will ever be gone through more than once, so it's not really a loop. What's the point of this outer loop?

commented: I agree, 1000+ lines is just taking the piss +19

I removed the int val and changed withdrawmoney to just money. Can we first just start with helping me with getting the error if user withdraws more than 300 and we can go from there

You had another thread recently on a very similar topic that I responded to and you never responded back.

http://www.daniweb.com/forums/thread262999.html

I don't know if this is the same problem or not.

If you post 1200+ lines, you should point us in the right direction. A few things stand out:

Line 158 - What does val represent? It isn't used.
Lines 158 and 170 - What do money and withdrawmoney represent? You ask how much they want to withdraw and store it in money, not withdrawmoney, or you store it in val, or something. Not sure. If you're storing it in val, you never use val.
Line 173 - It's the same test as line 158. I can't see how the outer loop will ever be gone through more than once, so it's not really a loop. What's the point of this outer loop?

Can we first just start with helping me with getting the error if user withdraws more than 300 and we can go from there

I don't know what you mean here. Do you think I was just pointing that out to give you a hard time? Programming involves far more than fixing the code syntax itself. I'm trying to establish what your thought process is and I am showing you why it is hard to follow.

I AM helping you get to the bottom of that error. What I'm saying is what you had didn't make any sense. Apparently you've changed the code, but you haven't posted it. You need to post the relevant code, and only the relevant code, and explain what you are trying to do because the code made no sense and even with the correction, you still have an outer while loop that doesn't do anything.

You need to do something like this:

  1. Ask the user how much he wants to withdraw.
  2. Check whether it's legal input. If not, post an error message and go back to 1.
  3. If it is, check whether he's above the daily withdrawal amount (if any). If so, post an error, go back to 1.
  4. Check whether the person has enough money in their account. if not, post an error message, go back to 1.
  5. If all is good, adjust any balance variables, cumulative withdrawal variables, whatever, to reflect the new values.
  6. Post a message with the details of the transaction, new balance, whatever.
  7. Return to the main menu.

It's a step by step process and it should be designed with variable and function names and messages to the user that make it easy for the user to follow and the person reading to follow. Remove all variables, loops, and function calls that don't do anything. Good variable names would be stuff like "withdrawRequestAmount", cumulativeWithdrawalAmount", "maximumWithdrawalAmount", "accountBalance". Just write it in English:

bool validWithdrawalAmount = true;

do
{
// code
  if (accountBalance < withdrawRequestAmount)
  {
    validWithdrawAmount = false;
    // post error message
  }
// more code
}
while (!validWithdrawalAmount);

// now do the actual withdrawing

The variable names are obvious, so you hardly need to document anything.

no sir i apologize if that came off rude i meant no disrespect at all...I guess what i am meaning to say is I am average at actual programming so when someone is being tgechnical with me about it i dont understand so if i offended u i apologize...would it be ok if i send u the instructions and hopefully I can explain it better for what I am looking for?

Apology accepted. We try to do everything on the public forum, so it would be better to post the requirements on the thread rather than via PM. But yes, post them.

Is this a school assignment? Is there a spec that you need to follow? I presume that is what you are talking about. For code this long, it is best to program a segment of the program that is relevant to a particular question. If you want to, you can also post the entire program as an attachment. That's often very useful, so people can download and run the program if they choose, but if you put all that code in the post itself, generally people won't look at it. As important as good variable naming is in all programming, it's even more important when posting on a forum. The code segment and description should be enough to give people viewing it an understanding of what is going on, but not so much as to overwhelm them with irrelevant information to the pertinent question. Also, and I just noticed this, not everything in code tags is code. You have sentences in the middle, but we had no way of telling where they were, so I just figured the whole thing was code.

So, to sum up,

  1. Explain in a short paragraph the requirements.
  2. If needed, also post the full requirements from the instructor.
  3. Post a relevant code snippet if the program is long.
  4. Explain what you are trying to do, what you've done, what the results are, what they should be, etc. Be concise, but also give detail.
  5. Provide any error messages, explain whether they are compile errors, run-time errors, and when they occur, etc.
  6. You can attach the entire program, but do it as an attachment.
  7. Use descriptive names for variables and functions. Add comments if it is not obvious.

So yes, post the requirements and the question and I'll look at it. Here's a very good guide that everyone should read.

http://www.catb.org/esr/faqs/smart-questions.html

commented: + Rep for all the help you gave, unfortunately the OP is a hopeless case.. +5

I would also suggest that once you solve your problem, to rethink your algorithm out and rewrite your program. It shouldnt take 1000 lines of code to right a simple atm program. Practice makes you a better programmer.

Here are my instructions and here are two of my issues. For one when I enter more than 300 it goes through but it should return an error. However when I enter it again it then returns an error. However when I use another pin number it says I have exceeded the 300 in a day. Also with the issue wtih depositing over 10,000 it returns a value of withdraw as well. I am now attaching my code and instructions. I know there is a lot of code so please do tell me if it hard to follow and ill try to see what I can do to make it easier and thank you for all the help....

ATM REQUIREMENTS

3/8/2010

Requirements
1 - only direct account transactions will be done on this ATM (
2 - assume this ATM is a bank ATM, no transaction fees.
3 - this application will be a 'dos' application
4 - app should be able to cancel at any point via back (goes to main menu, screen 4 and beyond) or exit atm (screens 2 & 3)
5 - max 3 times to attemp to log in, after 3 invalid entries show message "your account has been locked."
6 - this is a swipe machine (Person needs to simulate a swipe "could be pressing a button or entering something on the screen" person needs to enter a pin number.
7 - every screen will have a feedback line on line 1 (Optional)
8 - Can only hold 10,000 dollars before ATM displays cannot accept any additional deposits.
9 - Any withdrawl has to be in $20 amounts, transfers don't have this limitation
10 - Account files will be prepopulated
11 - User can only withdrawl $300 amount per day
12 - Every transaction has a date/time stamp, account number
13 - Information only on screen, or printed/receipts

Welcome Screen (screen 1)
"hit enter to simulate inserting card"

Data Entry Screen (screen 2)
1) account pin: (resides in a file)
2) exit ATM
-if valid got to main menu
-else, display "invalid account # and/or pin#"

Main Menu Screen (screen 3)
1) withdrawl
2) deposit
3) check balance
4) funds transfer
5) exit ATM

Withdrawl Screen (screen 4.a)
1) from checking
2) from savings
3) quick cash /* optional */
4) back to main menu

Deposit Screen (screen 4.b)
1) to checking
2) to savings
3) back to main menu

Check Balance Screen (screen 4.c)
1) from checking
2) from savings
3) back to main menu

Funds Transfer Screen (screen 4.d)
1) from savings to checking
2) from checking to savings
3) back to main menu

Enter Amount Screen (screen 5.a)
1) Enter Amount
2) back to main menu

Quick Cash Amount Screen (screen 5.b)
1) $20.00
2) $40.00
3) $60.00
4) $80.00
5) $100.00
6) back to main menu

Would you like to perform another transaction (screen 6)
-if yes, go back to screen 2
-else, go to screen 7

Goodbye Screen (screen 7)
display goodbye message, wait 10 seconds, cycle back to welcome screen

/* optional 
Maintenance Screen (screen 8) 
requires a special pin
1) update money supply 
2) exit ATM */

//Begin coding the program
#include <iostream>
#include <iomanip>
#include <time.h>
#include <fstream>
#include <conio.h>
#include <string>

using namespace std;

//Function prototypes
void showMenu();
int mainMenuSelection(int);
void welcomeScreen();
double enterAmountScreen(double);
int anotherTransactionScreen(int);
void goodbyeScreen();
void wait(int);
int dataEntryScreen();
void timeStamp();
void depositTest(double);

//void withdrawMax();

/*
******************************************************************
******************************************************************
** MAIN FUNCTION                                                 *
** int main function                                             *
******************************************************************
******************************************************************
*/

int main ()
{
    //Declare variables
    int choice;

    //Set the numeric output formatting
    cout << fixed << showpoint << setprecision(2);

    //Function for welcome screen
    welcomeScreen();

    //Give space for the function of date and time
    cout << endl << endl;

    //Prompt to show today's date
    cout << "Today's date is: " << endl;

    //Show date and time function
    timeStamp();

    //Enter some space
    cout << endl << endl;

    //Function to enter a pin number
    choice = dataEntryScreen();

    //if statement for choice
    if (choice == -1)

        //Return a value
        return 0;

    //Create a do\while loop
    do
    {
        //Display the menu 
        showMenu();

        //get the user's choice.
        cin >> choice;

        //Validate the menu selection.
        while (choice < 1 || choice > 5)
        {
            //Prompt user to reenter a correct choice
            cout << "Please enter 1, 2, 3, 4, or 5: ";
            cin >> choice;

            //add color to error message
            //add color to error message
            system ("Color 3a");
        }

        //Function to choose in the main menu selection
        mainMenuSelection(choice);

    //End the while statement
    } while (choice != 5);

    //Function returns a value
    return 0;
}

/*
***********************************************************
***********************************************************
* Main Menu Function                                      *
* Function to show the main menu                          *
***********************************************************
***********************************************************
*/

void showMenu()
    {
        //Display the main menu screen
        cout << endl << "\t\tMain Menu Screen" << endl << endl;
        cout << "1) Withdrawal" << endl;
        cout << "2) Deposit" << endl;
        cout << "3) Check Balance" << endl;
        cout << "4) Funds Transfer" << endl;
        cout << "5) Exit ATM" << endl << endl;
        cout << "Please enter a selection: ";

        //add color to background of main menu screen
        //add color to text of main menu screen
        system ("Color 1a");
    }

/*    
*********************************************************************
*********************************************************************
* Main Menu Screen                                                  *
* Function to choose in the main menu screen                        *
*********************************************************************
*********************************************************************
*/

int mainMenuSelection(int choice)
    {
        //Declare variables in mainMenuSelection
        int withdrawChoice,
            depositChoice,
            checkBalanceChoice,
            fundsTransferChoice;
        double money = 0.0;

        //Respond to user's menu selection
        switch (choice)
        {
        //switch case 1
        case 1:

            //Perform do\while loop to check for correct validation
            do
            {
                //let customer know he\she cannot withdraw more than 300 per day
                cout << endl << "You may not withdraw more than $300 for this date:" << endl << endl;

                //function to enter date and time
                timeStamp();

                //give some spaces from main menu
                cout << endl;

                //Show output of function
                cout << endl << "\t\tWithdrawal Screen" << endl << endl;
                cout << "1) From Checking" << endl;
                cout << "2) From Savings" << endl;
                cout << "3) Quick Cash" << endl;
                cout << "4) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> withdrawChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6a");

                //While statement to check validation
                while (withdrawChoice < 1 || withdrawChoice > 4)
                {
                    //Prompt user to reenter a correct number
                    cout << "Please reenter 1, 2, 3, 4: ";
                    cin >> withdrawChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }

                //Perform if statement
                if (withdrawChoice != 4)
                {
                    do
                    {
                    //Declare variables
                    int val = enterAmountScreen(money);

                    //Enter a while loop
                    while (money > 300)
                    {
                        //Display error message
                        cout << "An error has occurred!" << endl;
                        cout << "You have withdrawn more than the max allowed per day!" << endl;
                        cout << "Please enter a withdraw amount less than or equal to $300: ";
                        cin >> money;

                        //add color to error message
                        //add color to error message
                        system ("Color 3a");
                    }

                    //Show the amount withdrawn
                    cout << "You have withdrawn $" << money << endl;

                    //Perform another while statement
                    } while (money > 300);

                    //Return the value
                    return -1;
                }

            //Complete do\while statement
            } while (withdrawChoice != 4);

            //Back to main menu option
            if (withdrawChoice == 4)
            {
                //Return a value
                return -1;
            }

            //Perform a break to go to next case
            break;

        //Perform case 2
        case 2:

            //Perform do\while loop to check for correct validation
            do
            {
                //Display output of Deposit Screen
                cout << endl << "\t\tDeposit Screen" << endl << endl;
                cout << "1) To Checking" << endl;
                cout << "2) To Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> depositChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6b");

                //Check for validation
                while (depositChoice < 1 || depositChoice > 3)
                {
                    //Prompt user to enter a correct choice
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> depositChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }

                //Perform an if statment
                if (depositChoice !=3)
                {
                    //Declare value in function
                    int val = enterAmountScreen(money);
                }

            //end do\while loop
            } while (depositChoice != 3);

            //Back to main menu option
            if (depositChoice == 3)
            {
                //Return a value
                return -1;
            }

            //Perform a break to go to next case
            break;

        //Prompt to enter case 3
        case 3:

            //Perform do\while loop to check for correct validation
            do
            {
                //Display output
                cout << "\t\tCheck Balance Screen" << endl << endl;
                cout << "1) From Checking" << endl;
                cout << "2) From Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Enter enter a selection: ";
                cin >> checkBalanceChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6c");

                //Check for validation
                while (checkBalanceChoice < 1 || checkBalanceChoice > 3)
                {
                    //Check for validation
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> checkBalanceChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }

            //End while statement
            } while (checkBalanceChoice != 3);

            //Back to main menu option
            if (checkBalanceChoice ==3)
            {
                //Return a value
                return -1;
            }

            //Perform break to go to next case
            break;

        //Prompt to begin case 4
        case 4:

            //Perform do\while loop to check for correct validation
            do
            {
                //Display output
                cout << "\t\tFunds Transfer Screen" << endl << endl;
                cout << "1) From Savings to Checking" << endl;
                cout << "2) From Checking to Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> fundsTransferChoice;

                //add color to background of withdraw screen
                //add color to text of main menu screen
                system ("Color 6d");

                //Check for validation
                while (fundsTransferChoice < 1 || fundsTransferChoice > 3)
                {
                    //Prompt user to enter correct selection
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> fundsTransferChoice;

                    //add color to error message
                    //add color to error message
                    system ("Color 3a");
                }

                //Perform if statement
                if (fundsTransferChoice != 3)
                {
                    //Declare values in function
                    int val = enterAmountScreen(money);

                    //Return a value
                    return -1;
                }

            //End do while loop
            } while (fundsTransferChoice != 3);

            //Back to main menu option
            if (choice == 3)
            {
                //Return a value
                return -1;
            }

            //Prompt to break to next case
            break;

        //Prompt to enter next case
        case 5:

            //End the program if 5 is selected
            cout << "Program ending." << endl << endl;

            //add color to background of withdraw screen
            //add color to text of main menu screen
            system ("Color 6e");

            //Perform break
            break;
        }

        //Returns a value
        return 0;
    }

/*
**********************************************************
**********************************************************
* Welcome Screen                                         *
* Function to display the welcome screen                 *
**********************************************************
**********************************************************
*/
void welcomeScreen()
        {
            //Show output of function
            cout << "Hit enter to simulate inserting card";

            //Hit enter to go to the next screen
            cin.get();

        //add color to background of main menu screen
        //add color to text of main menu screen
        system ("Color 1b");
        }

/*
**********************************************************
**********************************************************
* Enter amount screen                                    *
* Function to enter amount screen                        *
**********************************************************
**********************************************************
*/

double enterAmountScreen(double money)
{
    //Declare function variables
    int decision,
    anotherTransactionChoice = 0;

    //prompt user to begin do statemen
    do
    {
        //Show output of function
        cout << endl << "\t\tEnter Amount Screen" << endl;
        cout << "1) Enter an amount:";
        cout << endl << "2) Back to Main Menu:";
        cout << endl << "Please enter a selection: ";
        cin >> decision;

        //add color to background of enter amount screen
        //add color to text of enter amount screen
        system ("Color 1c");

        /*
        *******************************************
        * Return to main menu option              *
        * Create if statement for decision        *
        *******************************************
        */

        //Create while statement for decision
        while (decision < 1 || decision > 2)
        {
            //Enter a correct number
            cout << "Please reenter 1 or 2: ";
            cin >> decision;

            //add color to error message
            //add color to error message
            system ("Color 3a");
        }

        //use an if statement
        if (decision == 2)
        {
            //return a value
            return -1;
        }

        //Perform next if statement
        if (decision == 1)
        {
            //Prompt user to enter the amount
            cout << "Please enter the amount: ";
            cin >> money;

            //Enter a depositTest function
            depositTest(money);
        }

        //enter while for a decision
        } while (decision < 1 || decision > 2);


        //Perform anotherTransactionScreen function
        anotherTransactionScreen(anotherTransactionChoice);

        //Create a space
        cout << endl;

        //Perform timeStamp function
        timeStamp();

    //Return a value
    return money;

}

/*
***********************************************************************
***********************************************************************
* Another Transaction Screen                                          *
* Function to enter another transaction screen                        *
***********************************************************************
***********************************************************************
*/

int anotherTransactionScreen(int anotherTransactionChoice)
{
    //Perform a do statement
    do
    {
        //Display output
        cout << endl << "\t\tAnother Transaction Screen" << endl;
        cout << "1.) Enter another transaction" << endl;
        cout << "2.) Exit the ATM ";
        cout << endl << "Please enter a selection: ";
        cin >> anotherTransactionChoice;

        //add color to background of another transaction screen
        //add color to text of another transaction screen
        system ("Color 1d");

        /*
        ********************************************************************
        ********************************************************************
        * Check for validation                                             *
        * Use while statement                                              *
        ********************************************************************
        ********************************************************************
        */

        //Perform while statement
        while (anotherTransactionChoice < 1 || anotherTransactionChoice > 2)
        {
            //Enter a correct number
            cout << "Please reenter 1 or 2: ";
            cin >> anotherTransactionChoice;

            //add color to error message
            //add color to error message
            system ("Color 3a");
        }

        //If statement to return to main menu
        if (anotherTransactionChoice == 1)
        {
            //Return a value
            return -1;
        }

        //If statement to display the goodbye screen and exit
        if (anotherTransactionChoice == 2)
        {
            //Go to goodbye function
            goodbyeScreen();

            //Return a value
            return 1;
        }

    //end do\while statement
    } while (anotherTransactionChoice == 2 || anotherTransactionChoice == 1);

    //Return a value
    return anotherTransactionChoice;
}

/*
***************************************************************
***************************************************************
* Goodbye Screen                                              *
* Function to display goodbye Screen                          *
***************************************************************
***************************************************************
*/

void goodbyeScreen()
{
    //Declare variables in goodbye screen
    int seconds = 10;

    //Display a goodbye message
    cout << endl << endl << "Have a nice day!" << endl << endl;
    wait(seconds);

    //add color to background of goodbye screen
    //add color to text of googbye screen
        system ("Color 1f");
}

/*
*****************************************************************
*****************************************************************
* Wait function                                                 *
* Function to wait 10 seconds before returning to main menu     *
*****************************************************************
*****************************************************************
*/

void wait(int seconds)
{
    //Declare variables
    clock_t endwait;

    //Calculate seconds
    endwait = clock () + seconds * CLK_TCK ;

    //Perform while statement for seconds
    while (clock() < endwait) {}
}


/*
***********************************************************
***********************************************************
* Enter pin                                               *
* Function to enter a pin number                          *
***********************************************************
***********************************************************
*/

int dataEntryScreen()
{
    //Declare variables
    string valid,
           pin;
    bool found = false;
    int pinChoice,
        i,
        j = 3;
    ifstream Input;

    //Perform do\while loop to check for correct validation
    do
    {
        //Display the output
        cout << "\t\tData Entry Screen";
        cout << endl << "1) Enter pin number";
        cout << endl << "2) Exit the ATM";
        cout << endl << "Please enter a selection: ";
        cin >> pinChoice;

        //add color to background of data entry screen
        //add color to text of data entry screen
        system ("Color 3c");

        /*
        **********************************************
        **********************************************
        * Check for validation                       *
        * Use while statement                        *
        **********************************************
        **********************************************
        */

        //Perform while statement
        while (pinChoice < 1 || pinChoice > 2)
        {
            //Enter a correct choice
            cout << "Please reenter 1 or 2: ";
            cin >> pinChoice;

            //add color to error message
            //add color to error message
            system ("Color 3a");
        }

        //If statement if 2 is selected
        if (pinChoice == 2)
        {
            //exit the atm and returning a value
            return -1;
        }

    //end do\while loop
    } while (pinChoice > 2 || pinChoice < 1);

    /*
    *******************************************
    *******************************************
    * If statement 1 is selected              *
    * Perform for loop                        *
    *******************************************
    *******************************************
    */

    for (j = 0; j < 3; j++)
    {
        //Prompt user to enter pin number
        cout << "Please enter your 4 character pin number ";
        cin >> pin;

    //Open the file
    Input.open("pin.txt");  

    //Perform error test
    if(Input.fail( ))
    {
        //Display error opening file.
        cout << endl << "Error opening input file" << endl;

        //add color to error message
        //add color to error message
        system ("Color 3a");
    }

    //Determine if false
    found = false;

    //Input valid
    Input >> valid;

    //Perform while statement
    while (Input && !found)
    {
        //Perform for loop
        for (i = 0; i < 5; i++)
        {
            //if statement for pin
             if (pin[i] != valid[i])
            i = 6;
        }

        //Determine if true with if statement
        if (i == 5)
            found = true;

        //Perform else statement
        else
            Input >> valid;
    }

    //Skip a line
    cout << endl;

    //Close the file
    Input.close();

    //Clear the file
    Input.clear();

    //If statement if pin number found
    if (found)

        //Return a value
        return 0;

    //Allow only 3 chances for pin to be valid
    if (j < 2)

    //Output for invalid pin number
    cout << endl << "Invalid pin";
    cout << endl << "You have " << 2-j << " more tries" << endl << endl;

    //add color to error message
    //add color to error message
    system ("Color 3a");
}

    //If statement if pin number is wrong three times
    if (!found)
    {
        //Display output of wrong pin three times
        cout << endl << "Invalid pin";
        cout << endl << "System aborting";
        cout << endl << "Your account has been locked" << endl;

        //Add a pause to the program
        system("pause");

        //add color to error message
        //add color to error message
        system ("Color 3a");

        //Return a value
        return -1;
    }
}   

/*
********************************************************************
********************************************************************
* Enter timestamp                                                  *
* Function to enter timestamp                                      *
********************************************************************
********************************************************************
*/

void timeStamp()
{
    //Calendar time
     time_t ltime;

     //Get current cal time
     ltime=time(NULL);

     //Prints out the results
     printf("%s",asctime( localtime(&ltime) ) );
}

/*
*********************************************************
* Withdraw Max                                          *
* Function to place a limit on                          *
* drawing the max cash                                  *
*********************************************************
*/

//double withdrawMax(double money)
//{

//

/*
***********************************************************
* Deposit Test                                            *
* Function to determine if atm has room                   *
* to make a deposit                                       *
***********************************************************
*/

void depositTest(double money)
{

    //if money is greater than 10000 if statement
    if (money > 10000)
    {
        //show an error message
        cout << endl << "This ATM has encountered one of the following errors...";
        cout << endl << "1. This atm has reached the total amount of deposits it can hold.";
        cout << endl << "2. There is not enough cash available to withdraw this amount.";
        cout << endl << "We apologize for this inconvenience.";
        cout << endl << "Please enter a smaller transaction.";
        cout << endl;

        //exit to prompt user to the enter another transaction screen
        exit;
    }
}

Apology accepted. We try to do everything on the public forum, so it would be better to post the requirements on the thread rather than via PM. But yes, post them.

Is this a school assignment? Is there a spec that you need to follow? I presume that is what you are talking about. For code this long, it is best to program a segment of the program that is relevant to a particular question. If you want to, you can also post the entire program as an attachment. That's often very useful, so people can download and run the program if they choose, but if you put all that code in the post itself, generally people won't look at it. As important as good variable naming is in all programming, it's even more important when posting on a forum. The code segment and description should be enough to give people viewing it an understanding of what is going on, but not so much as to overwhelm them with irrelevant information to the pertinent question. Also, and I just noticed this, not everything in code tags is code. You have sentences in the middle, but we had no way of telling where they were, so I just figured the whole thing was code.

So, to sum up,

  • Explain in a short paragraph the requirements.
  • If needed, also post the full requirements from the instructor.
  • Post a relevant code snippet if the program is long.
  • Explain what you are trying to do, what you've done, what the results are, what they should be, etc. Be concise, but also give detail.
  • Provide any error messages, explain whether they are compile errors, run-time errors, and when they occur, etc.
  • You can attach the entire program, but do it as an attachment.
  • Use descriptive names for variables and functions. Add comments if it is not obvious.

So yes, post the requirements and the question and I'll look at it. Here's a very good guide that everyone should read.

http://www.catb.org/esr/faqs/smart-questions.html

apologize for the missing code tags and in regards to the size we are required to minimum of 1000 lines

//Begin coding the program
#include <iostream>
#include <iomanip>
#include <time.h>
#include <fstream>
#include <conio.h>
#include <string>
 
using namespace std;

//Function prototypes
void showMenu();
int mainMenuSelection(int);
void welcomeScreen();
double enterAmountScreen(double);
int anotherTransactionScreen(int);
void goodbyeScreen();
void wait(int);
int dataEntryScreen();
void timeStamp();
void depositTest(double);

//void withdrawMax();

/*
******************************************************************
******************************************************************
** MAIN FUNCTION                                                 *
** int main function                                             *
******************************************************************
******************************************************************
*/

int main ()
{
    //Declare variables
    int choice;
    
	//Set the numeric output formatting
    cout << fixed << showpoint << setprecision(2);

    //Function for welcome screen
    welcomeScreen();

	//Give space for the function of date and time
	cout << endl << endl;

	//Prompt to show today's date
	cout << "Today's date is: " << endl;

	//Show date and time function
	timeStamp();

	//Enter some space
	cout << endl << endl;

    //Function to enter a pin number
    choice = dataEntryScreen();

	//if statement for choice
	if (choice == -1)

		//Return a value
		return 0;

    //Create a do\while loop
    do
    {
        //Display the menu 
        showMenu();

		//get the user's choice.
        cin >> choice;

        //Validate the menu selection.
        while (choice < 1 || choice > 5)
        {
			//Prompt user to reenter a correct choice
            cout << "Please enter 1, 2, 3, 4, or 5: ";
            cin >> choice;

			//add color to error message
			//add color to error message
			system ("Color 3a");
        }
        
        //Function to choose in the main menu selection
        mainMenuSelection(choice);

	//End the while statement
    } while (choice != 5);
    
	//Function returns a value
    return 0;
}
 
/*
***********************************************************
***********************************************************
* Main Menu Function                                      *
* Function to show the main menu                          *
***********************************************************
***********************************************************
*/

void showMenu()
    {
		//Display the main menu screen
        cout << endl << "\t\tMain Menu Screen" << endl << endl;
        cout << "1) Withdrawal" << endl;
        cout << "2) Deposit" << endl;
        cout << "3) Check Balance" << endl;
        cout << "4) Funds Transfer" << endl;
        cout << "5) Exit ATM" << endl << endl;
        cout << "Please enter a selection: ";

		//add color to background of main menu screen
		//add color to text of main menu screen
		system ("Color 1a");
	}

/*    
*********************************************************************
*********************************************************************
* Main Menu Screen                                                  *
* Function to choose in the main menu screen                        *
*********************************************************************
*********************************************************************
*/

int mainMenuSelection(int choice)
    {
        //Declare variables in mainMenuSelection
        int withdrawChoice,
            depositChoice,
            checkBalanceChoice,
            fundsTransferChoice;
		double money = 0.0;
		
		//Respond to user's menu selection
        switch (choice)
		{
		//switch case 1
        case 1:

            //Perform do\while loop to check for correct validation
            do
            {
				//let customer know he\she cannot withdraw more than 300 per day
				cout << endl << "You may not withdraw more than $300 for this date:" << endl << endl;

				//function to enter date and time
				timeStamp();

				//give some spaces from main menu
				cout << endl;

                //Show output of function
                cout << endl << "\t\tWithdrawal Screen" << endl << endl;
                cout << "1) From Checking" << endl;
                cout << "2) From Savings" << endl;
                cout << "3) Quick Cash" << endl;
                cout << "4) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> withdrawChoice;

				//add color to background of withdraw screen
				//add color to text of main menu screen
				system ("Color 6a");

				//While statement to check validation
                while (withdrawChoice < 1 || withdrawChoice > 4)
                {
					//Prompt user to reenter a correct number
                    cout << "Please reenter 1, 2, 3, 4: ";
                    cin >> withdrawChoice;

					//add color to error message
					//add color to error message
					system ("Color 3a");
                }

				//Perform if statement
                if (withdrawChoice != 4)
                {
					do
					{
					//Declare variables
                    int val = enterAmountScreen(money);
					
					//Enter a while loop
					while (money > 300)
					{
						//Display error message
						cout << "An error has occurred!" << endl;
						cout << "You have withdrawn more than the max allowed per day!" << endl;
						cout << "Please enter a withdraw amount less than or equal to $300: ";
						cin >> money;

						//add color to error message
						//add color to error message
						system ("Color 3a");
					}

					//Show the amount withdrawn
					cout << "You have withdrawn $" << money << endl;

					//Perform another while statement
					} while (money > 300);

					//Return the value
                    return -1;
                }
             
			//Complete do\while statement
            } while (withdrawChoice != 4);
            
            //Back to main menu option
            if (withdrawChoice == 4)
            {
				//Return a value
                return -1;
            }

			//Perform a break to go to next case
            break;
		
		//Perform case 2
        case 2:

            //Perform do\while loop to check for correct validation
            do
            {
				//Display output of Deposit Screen
                cout << endl << "\t\tDeposit Screen" << endl << endl;
                cout << "1) To Checking" << endl;
                cout << "2) To Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> depositChoice;

				//add color to background of withdraw screen
				//add color to text of main menu screen
				system ("Color 6b");
				
				//Check for validation
                while (depositChoice < 1 || depositChoice > 3)
                {
					//Prompt user to enter a correct choice
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> depositChoice;

					//add color to error message
					//add color to error message
					system ("Color 3a");
                }

				//Perform an if statment
                if (depositChoice !=3)
                {
					//Declare value in function
                    int val = enterAmountScreen(money);
				}

			//end do\while loop
            } while (depositChoice != 3);

            //Back to main menu option
            if (depositChoice == 3)
            {
				//Return a value
                return -1;
            }

			//Perform a break to go to next case
            break;

		//Prompt to enter case 3
        case 3:

            //Perform do\while loop to check for correct validation
            do
            {
				//Display output
                cout << "\t\tCheck Balance Screen" << endl << endl;
                cout << "1) From Checking" << endl;
                cout << "2) From Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Enter enter a selection: ";
                cin >> checkBalanceChoice;

				//add color to background of withdraw screen
				//add color to text of main menu screen
				system ("Color 6c");
				
				//Check for validation
                while (checkBalanceChoice < 1 || checkBalanceChoice > 3)
                {
					//Check for validation
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> checkBalanceChoice;

					//add color to error message
					//add color to error message
					system ("Color 3a");
                }

			//End while statement
            } while (checkBalanceChoice != 3);

            //Back to main menu option
            if (checkBalanceChoice ==3)
            {
				//Return a value
                return -1;
            }

			//Perform break to go to next case
            break;

		//Prompt to begin case 4
        case 4:

            //Perform do\while loop to check for correct validation
            do
            {
				//Display output
                cout << "\t\tFunds Transfer Screen" << endl << endl;
                cout << "1) From Savings to Checking" << endl;
                cout << "2) From Checking to Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> fundsTransferChoice;

				//add color to background of withdraw screen
				//add color to text of main menu screen
				system ("Color 6d");

				//Check for validation
                while (fundsTransferChoice < 1 || fundsTransferChoice > 3)
                {
					//Prompt user to enter correct selection
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> fundsTransferChoice;

					//add color to error message
					//add color to error message
					system ("Color 3a");
                }
                
				//Perform if statement
                if (fundsTransferChoice != 3)
                {
					//Declare values in function
                    int val = enterAmountScreen(money);

					//Return a value
                    return -1;
                }

			//End do while loop
            } while (fundsTransferChoice != 3);

            //Back to main menu option
            if (choice == 3)
            {
				//Return a value
                return -1;
            }

			//Prompt to break to next case
            break;

		//Prompt to enter next case
        case 5:

            //End the program if 5 is selected
            cout << "Program ending." << endl << endl;

			//add color to background of withdraw screen
			//add color to text of main menu screen
			system ("Color 6e");

			//Perform break
            break;
        }

		//Returns a value
        return 0;
    }

/*
**********************************************************
**********************************************************
* Welcome Screen                                         *
* Function to display the welcome screen                 *
**********************************************************
**********************************************************
*/
void welcomeScreen()
        {
            //Show output of function
            cout << "Hit enter to simulate inserting card";

            //Hit enter to go to the next screen
            cin.get();

		//add color to background of main menu screen
		//add color to text of main menu screen
		system ("Color 1b");
        }

/*
**********************************************************
**********************************************************
* Enter amount screen                                    *
* Function to enter amount screen                        *
**********************************************************
**********************************************************
*/

double enterAmountScreen(double money)
{
    //Declare function variables
    int decision,
    anotherTransactionChoice = 0;
            
	//prompt user to begin do statemen
	do
	{
		//Show output of function
		cout << endl << "\t\tEnter Amount Screen" << endl;
		cout << "1) Enter an amount:";
		cout << endl << "2) Back to Main Menu:";
		cout << endl << "Please enter a selection: ";
		cin >> decision;

		//add color to background of enter amount screen
		//add color to text of enter amount screen
		system ("Color 1c");

		/*
		*******************************************
		* Return to main menu option              *
		* Create if statement for decision        *
		*******************************************
		*/

		//Create while statement for decision
		while (decision < 1 || decision > 2)
		{
			//Enter a correct number
			cout << "Please reenter 1 or 2: ";
			cin >> decision;

			//add color to error message
			//add color to error message
			system ("Color 3a");
		}

		//use an if statement
		if (decision == 2)
		{
			//return a value
			return -1;
		}

		//Perform next if statement
		if (decision == 1)
		{
			//Prompt user to enter the amount
			cout << "Please enter the amount: ";
			cin >> money;
			
			//Enter a depositTest function
			depositTest(money);
		}

		//enter while for a decision
		} while (decision < 1 || decision > 2);
	

		//Perform anotherTransactionScreen function
		anotherTransactionScreen(anotherTransactionChoice);

		//Create a space
		cout << endl;

		//Perform timeStamp function
		timeStamp();
    
	//Return a value
    return money;

}

/*
***********************************************************************
***********************************************************************
* Another Transaction Screen                                          *
* Function to enter another transaction screen                        *
***********************************************************************
***********************************************************************
*/

int anotherTransactionScreen(int anotherTransactionChoice)
{
	//Perform a do statement
    do
    {
		//Display output
        cout << endl << "\t\tAnother Transaction Screen" << endl;
        cout << "1.) Enter another transaction" << endl;
        cout << "2.) Exit the ATM ";
        cout << endl << "Please enter a selection: ";
        cin >> anotherTransactionChoice;

		//add color to background of another transaction screen
		//add color to text of another transaction screen
		system ("Color 1d");
		
		/*
		********************************************************************
		********************************************************************
		* Check for validation                                             *
		* Use while statement                                              *
		********************************************************************
		********************************************************************
		*/
		
		//Perform while statement
        while (anotherTransactionChoice < 1 || anotherTransactionChoice > 2)
        {
			//Enter a correct number
            cout << "Please reenter 1 or 2: ";
            cin >> anotherTransactionChoice;

			//add color to error message
			//add color to error message
			system ("Color 3a");
        }

		//If statement to return to main menu
        if (anotherTransactionChoice == 1)
        {
			//Return a value
            return -1;
        }
		
		//If statement to display the goodbye screen and exit
        if (anotherTransactionChoice == 2)
        {
			//Go to goodbye function
            goodbyeScreen();

			//Return a value
            return 1;
        }
	
	//end do\while statement
    } while (anotherTransactionChoice == 2 || anotherTransactionChoice == 1);

	//Return a value
    return anotherTransactionChoice;
}

/*
***************************************************************
***************************************************************
* Goodbye Screen                                              *
* Function to display goodbye Screen                          *
***************************************************************
***************************************************************
*/

void goodbyeScreen()
{
    //Declare variables in goodbye screen
    int seconds = 10;

    //Display a goodbye message
    cout << endl << endl << "Have a nice day!" << endl << endl;
    wait(seconds);

	//add color to background of goodbye screen
	//add color to text of googbye screen
		system ("Color 1f");
}

/*
*****************************************************************
*****************************************************************
* Wait function                                                 *
* Function to wait 10 seconds before returning to main menu     *
*****************************************************************
*****************************************************************
*/

void wait(int seconds)
{
	//Declare variables
    clock_t endwait;

	//Calculate seconds
    endwait = clock () + seconds * CLK_TCK ;

	//Perform while statement for seconds
    while (clock() < endwait) {}
}


/*
***********************************************************
***********************************************************
* Enter pin                                               *
* Function to enter a pin number                          *
***********************************************************
***********************************************************
*/

int dataEntryScreen()
{
    //Declare variables
	string valid,
	       pin;
	bool found = false;
	int pinChoice,
		i,
		j = 3;
	ifstream Input;

    //Perform do\while loop to check for correct validation
    do
    {
        //Display the output
        cout << "\t\tData Entry Screen";
        cout << endl << "1) Enter pin number";
        cout << endl << "2) Exit the ATM";
        cout << endl << "Please enter a selection: ";
        cin >> pinChoice;

		//add color to background of data entry screen
		//add color to text of data entry screen
		system ("Color 3c");

		/*
		**********************************************
		**********************************************
		* Check for validation                       *
		* Use while statement                        *
		**********************************************
		**********************************************
		*/

		//Perform while statement
		while (pinChoice < 1 || pinChoice > 2)
        {
			//Enter a correct choice
            cout << "Please reenter 1 or 2: ";
            cin >> pinChoice;

			//add color to error message
			//add color to error message
			system ("Color 3a");
        }

        //If statement if 2 is selected
        if (pinChoice == 2)
        {
			//exit the atm and returning a value
            return -1;
        }

	//end do\while loop
    } while (pinChoice > 2 || pinChoice < 1);

	/*
	*******************************************
	*******************************************
	* If statement 1 is selected              *
	* Perform for loop                        *
	*******************************************
	*******************************************
	*/

	for (j = 0; j < 3; j++)
	{
		//Prompt user to enter pin number
		cout << "Please enter your 4 character pin number ";
		cin >> pin;
		
	//Open the file
    Input.open("pin.txt");  
    
    //Perform error test
    if(Input.fail( ))
    {
        //Display error opening file.
        cout << endl << "Error opening input file" << endl;

		//add color to error message
		//add color to error message
		system ("Color 3a");
    }

	//Determine if false
	found = false;

	//Input valid
	Input >> valid;

	//Perform while statement
	while (Input && !found)
	{
		//Perform for loop
		for (i = 0; i < 5; i++)
		{
			//if statement for pin
			 if (pin[i] != valid[i])
			i = 6;
		}

		//Determine if true with if statement
		if (i == 5)
			found = true;

		//Perform else statement
		else
			Input >> valid;
	}
    
	//Skip a line
	cout << endl;

	//Close the file
    Input.close();

	//Clear the file
	Input.clear();

	//If statement if pin number found
	if (found)

		//Return a value
		return 0;

	//Allow only 3 chances for pin to be valid
	if (j < 2)

	//Output for invalid pin number
	cout << endl << "Invalid pin";
	cout << endl << "You have " << 2-j << " more tries" << endl << endl;

	//add color to error message
	//add color to error message
	system ("Color 3a");
}

	//If statement if pin number is wrong three times
	if (!found)
	{
		//Display output of wrong pin three times
		cout << endl << "Invalid pin";
		cout << endl << "System aborting";
		cout << endl << "Your account has been locked" << endl;

		//Add a pause to the program
		system("pause");

		//add color to error message
		//add color to error message
		system ("Color 3a");

		//Return a value
		return -1;
	}
}	

/*
********************************************************************
********************************************************************
* Enter timestamp                                                  *
* Function to enter timestamp                                      *
********************************************************************
********************************************************************
*/

void timeStamp()
{
	//Calendar time
	 time_t ltime;

	 //Get current cal time
	 ltime=time(NULL);

	 //Prints out the results
	 printf("%s",asctime( localtime(&ltime) ) );
}

/*
*********************************************************
* Withdraw Max                                          *
* Function to place a limit on                          *
* drawing the max cash                                  *
*********************************************************
*/

//double withdrawMax(double money)
//{
	
//

/*
***********************************************************
* Deposit Test                                            *
* Function to determine if atm has room                   *
* to make a deposit                                       *
***********************************************************
*/

void depositTest(double money)
{

	//if money is greater than 10000 if statement
	if (money > 10000)
	{
		//show an error message
		cout << endl << "This ATM has encountered one of the following errors...";
		cout << endl << "1. This atm has reached the total amount of deposits it can hold.";
		cout << endl << "2. There is not enough cash available to withdraw this amount.";
		cout << endl << "We apologize for this inconvenience.";
		cout << endl << "Please enter a smaller transaction.";
		cout << endl;

		//exit to prompt user to the enter another transaction screen
		exit;
	}
}
commented: Next time just edit your previous post -- or better yet use the PREVIEW button. -2

apologize for the missing code tags and in regards to the size we are required to minimum of 1000 lines

That doesn't mean you have to post every single line, does it? Just post the section that you are having trouble with.

And next time, just EDIT the previous post, don't repost another 1000 lines. Or better yet, use the PREVIEW button next to the SUBMIT button. You can verify the post looks right beforehand...


As it is, I'm not searching though all that code for your 300 problem without a road map (a code map :icon_mrgreen:). My guess is when you enter a value over 300 you don't clear it before returning.

Read post 3. It still applies. val is still unused. Use it or get rid of it. It serves no purpose except to confuse if it's there, but unused.

Do you expect money to change after line 190? You need to find out if it does. Place a cout statment before and after line 190 that displays money. If it hasn't changed and you are expecting it to, you need to check the function that is being called to make sure that:

  1. money is being passed by reference.
  2. money is changed within the function.

Read post 6, points 6 and 7. Point 6 - post the entire file as an ATTACHMENT. Post the relevant code and only the relevant code in the post itself. Point us to the appropriate line, tell us what you INTEND that line to do.

You need to either use a debugger and stick some breakpoints in to make sure that what you think is happening really is, or you need to stick some cout statements in there to display variable values and where you are. You need to know what the values SHOULD be and check them against what they actually are in order to pin it down.

Point 7 - again, variable names. val and money are too vague. This is an ATM program. You have nothing but values and money. Stick a comment in there to explain what the function call is supposed to do in line 190.

I don't understand why teachers require specifications like "You must have at least 1000 lines". None of mine ever did, thank God, and I can't imagine any reason an employer would. Generally you try to go the other way. Make the program smaller. But the assignment is the assignment.

Another point. Get the conio.h stuff out of there or at least stick some #ifdef testing (or other testing) in there so that those of us who don't have it (which I would imagine is most of us) can actually compile this program, or at least stick all the conio stuff in a function or whatever so we can comment it out really quick. Ditto with the system calls for the colored writing. Frankly I'm going to try that out. I never knew you could pick different colored writing from within a C++ program. That's kind of cool, but it's still a system call, so you may get the "System calls are bad" lecture, plus a lot of people get leary of running programs with system calls in them.

yes I completely agree which makes me posting additional necessary code. It looks like this is the only additional parts I have left of this program...

8 - Can only hold 10,000 dollars before ATM displays cannot accept any additional deposits.
9 - Any withdrawl has to be in $20 amounts, transfers don't have this limitation
11 - User can only withdrawl $300 amount per day
12 - Every transaction has a date/time stamp, account #

Id like to start with the every transaction has a date/time stamp and has the account pin number in it. I believe this is the code that I need to show you guys. My only issue is I need to put the pin number in the time stamp...

//Begin coding the program
#include <iostream>
#include <iomanip>
#include <time.h>
#include <fstream>
#include <conio.h>
#include <string>
#include <windows.h>
 
using namespace std;

//Function prototypes
void showMenu();
int mainMenuSelection(int);
void welcomeScreen();
double enterAmountScreen(double);
int anotherTransactionScreen(int);
void goodbyeScreen();
void wait(int);
int dataEntryScreen();
void timeStamp();
void depositTest(double);

//void withdrawMax();

/*
******************************************************************
******************************************************************
** MAIN FUNCTION                                                 *
** int main function                                             *
******************************************************************
******************************************************************
*/

int main ()
{
    //Declare variables
    int choice;
    
	//Set the numeric output formatting
    cout << fixed << showpoint << setprecision(2);

    //Function for welcome screen
    welcomeScreen();

	//Give space for the function of date and time
	cout << endl << endl;

	//Prompt to show today's date
	cout << "Today's date is: " << endl;

	//Show date and time function
	timeStamp();

	//Enter some space
	cout << endl << endl;

    //Function to enter a pin number
    choice = dataEntryScreen();

	//if statement for choice
	if (choice == -1)

		//Return a value
		return 0;

    //Create a do\while loop
    do
    {
        //Display the menu 
        showMenu();

		//get the user's choice.
        cin >> choice;

        //Validate the menu selection.
        while (choice < 1 || choice > 5)
        {
			//Prompt user to reenter a correct choice
            cout << "Please enter 1, 2, 3, 4, or 5: ";
            cin >> choice;

			//add beep to change in screen
			//add sleep to change in screen
			Beep (440, 500);
			Sleep (500);

			//add color to error message
			//add color to error message
			system ("Color 3a");
        }
        
        //Function to choose in the main menu selection
        mainMenuSelection(choice);

	//End the while statement
    } while (choice != 5);
    
	//Function returns a value
    return 0;
}

int dataEntryScreen()
{
    //Declare variables
	string valid,
	       pin;
	bool found = false;
	int pinChoice,
		i,
		j = 3;
	ifstream Input;

    //Perform do\while loop to check for correct validation
    do
    {
        //Display the output
        cout << "\t\tData Entry Screen";
        cout << endl << "1) Enter pin number";
        cout << endl << "2) Exit the ATM";
        cout << endl << "Please enter a selection: ";
        cin >> pinChoice;

		//add beep to change in screen
		//add sleep to change in screen
		Beep (440, 500);
		Sleep (500);

		//add color to background of data entry screen
		//add color to text of data entry screen
		system ("Color 3c");

		/*
		**********************************************
		**********************************************
		* Check for validation                       *
		* Use while statement                        *
		**********************************************
		**********************************************
		*/

		//Perform while statement
		while (pinChoice < 1 || pinChoice > 2)
        {
			//Enter a correct choice
            cout << "Please reenter 1 or 2: ";
            cin >> pinChoice;

			//add beep to change in screen
			//add sleep to change in screen
			Beep (440, 500);
			Sleep (500);

			//add color to error message
			//add color to error message
			system ("Color 3a");
        }

        //If statement if 2 is selected
        if (pinChoice == 2)
        {
			//exit the atm and returning a value
            return -1;
        }

	//end do\while loop
    } while (pinChoice > 2 || pinChoice < 1);

	/*
	*******************************************
	*******************************************
	* If statement 1 is selected              *
	* Perform for loop                        *
	*******************************************
	*******************************************
	*/

	for (j = 0; j < 3; j++)
	{
		//Prompt user to enter pin number
		cout << "Please enter your 4 character pin number ";
		cin >> pin;
		
	//Open the file
    Input.open("pin.txt");  
    
    //Perform error test
    if(Input.fail( ))
    {
        //Display error opening file.
        cout << endl << "Error opening input file" << endl;

		//add beep to change in screen
		//add sleep to change in screen
		Beep (440, 500);
		Sleep (500);

		//add color to error message
		//add color to error message
		system ("Color 3a");
    }

	//Determine if false
	found = false;

	//Input valid
	Input >> valid;

	//Perform while statement
	while (Input && !found)
	{
		//Perform for loop
		for (i = 0; i < 5; i++)
		{
			//if statement for pin
			 if (pin[i] != valid[i])
			i = 6;
		}

		//Determine if true with if statement
		if (i == 5)
			found = true;

		//Perform else statement
		else
			Input >> valid;
	}
    
	//Skip a line
	cout << endl;

	//Close the file
    Input.close();

	//Clear the file
	Input.clear();

	//If statement if pin number found
	if (found)

		//Return a value
		return 0;

	//Allow only 3 chances for pin to be valid
	if (j < 2)

	//Output for invalid pin number
	cout << endl << "Invalid pin";
	cout << endl << "You have " << 2-j << " more tries" << endl << endl;

	//add beep to change in screen
	//add sleep to change in screen
	Beep (440, 500);
	Sleep (500);

	//add color to error message
	//add color to error message
	system ("Color 3a");
}

	//If statement if pin number is wrong three times
	if (!found)
	{
		//Display output of wrong pin three times
		cout << endl << "Invalid pin";
		cout << endl << "System aborting";
		cout << endl << "Your account has been locked" << endl;

		//Add a pause to the program
		system("pause");

		//add beep to change in screen
		//add sleep to change in screen
		Beep (440, 500);
		Sleep (500);

		//add color to error message
		//add color to error message
		system ("Color 3a");

		//Return a value
		return -1;
	}
}	

void timeStamp()
{
	//Calendar time
	 time_t ltime;

	 //Get current cal time
	 ltime=time(NULL);

	 //Prints out the results
	 printf("%s",asctime( localtime(&ltime) ) );
}

I sent the attachment so please let me know if it did not work as well

Read post 3. It still applies. val is still unused. Use it or get rid of it. It serves no purpose except to confuse if it's there, but unused.

Do you expect money to change after line 190? You need to find out if it does. Place a cout statment before and after line 190 that displays money. If it hasn't changed and you are expecting it to, you need to check the function that is being called to make sure that:

  1. money is being passed by reference.
  2. money is changed within the function.

Read post 6, points 6 and 7. Point 6 - post the entire file as an ATTACHMENT. Post the relevant code and only the relevant code in the post itself. Point us to the appropriate line, tell us what you INTEND that line to do.

You need to either use a debugger and stick some breakpoints in to make sure that what you think is happening really is, or you need to stick some cout statements in there to display variable values and where you are. You need to know what the values SHOULD be and check them against what they actually are in order to pin it down.

Point 7 - again, variable names. val and money are too vague. This is an ATM program. You have nothing but values and money. Stick a comment in there to explain what the function call is supposed to do in line 190.

I don't understand why teachers require specifications like "You must have at least 1000 lines". None of mine ever did, thank God, and I can't imagine any reason an employer would. Generally you try to go the other way. Make the program smaller. But the assignment is the assignment.

Another point. Get the conio.h stuff out of there or at least stick some #ifdef testing (or other testing) in there so that those of us who don't have it (which I would imagine is most of us) can actually compile this program, or at least stick all the conio stuff in a function or whatever so we can comment it out really quick. Ditto with the system calls for the colored writing. Frankly I'm going to try that out. I never knew you could pick different colored writing from within a C++ program. That's kind of cool, but it's still a system call, so you may get the "System calls are bad" lecture, plus a lot of people get leary of running programs with system calls in them.

12 - Every transaction has a date/time stamp, account #

Id like to start with the every transaction has a date/time stamp and has the account pin number in it.

My only issue is I need to put the pin number in the time stamp...

I don't know what that code has to do with the timestamp/pin #/account #, and re-read point 12. It doesn't say pin #. It says account #. So are we talking about pin numbers or account numbers? If your problem doesn't have anything to do with pin numbers, you don't need to post the pin number code. You have the whole program posted as an attachment.

What exactly is the question? What doesn't work? Questions should be along the lines of something like this:

I've written a function called timeStamp () that is supposed to display the time and account number for each transaction. However, it displays "13245689" instead of "March 21, 2010: 12:03:09 p.m.". See line 220 for the function. It is called from line 123 after the user has successfully withdrawn 60 dollars.

That's an easy question to answer. We know exactly what the problem is, we know exactly what the function is supposed to do, we know exactly how it is misbehaving, and we know exactly where to look. We don't know at all what you are asking here, plus, as I noted, you aren't following the spec anyway. There is nothing about the pin number in the parts of the spec that you say you are having problems with (8, 9, 11, and 12).

Finally, the code formatting needs help. I imagine you are mixing tabs and spaces. Before posting, use Visual Studio or NetBeans or Emacs or gedit or whatever and change all tabs to spaces (I normally use 4 or 5 spaces for a tab) so everything lines up, because tabs are eight spaces on Daniweb and nothing lines up if you mix them, so no one can follow the code.

I've written a function called timeStamp () that is supposed to display the date, time and pin number for each transaction. However, it displays the date and time only. I am not sure how to add the pin number to the time stamp. My time stamp begins on line 287 and not sure the code to add for the pin number to be included in the complete time stamp. I hope this helps you guys out

I've written a function called timeStamp () that is supposed to display the date, time and pin number for each transaction. However, it displays the date and time only. I am not sure how to add the pin number to the time stamp. My time stamp begins on line 287 and not sure the code to add for the pin number to be included in the complete time stamp. I hope this helps you guys out

Read the spec. The timestamp isn't supposed to have the pin number. It's supposed to have the account number.

12 - Every transaction has a date/time stamp, account #

If you have a function that is supposed to display the account number, you need to make sure it has access to the account number. That means that the account number either must be passed to the function or it must be a global variable. Neither is the case in your program.

void timeStamp()  // no parameters

Sorry for not giving you all the information. Our professor has allowed the pin number to be the account number

Sorry for not giving you all the information. Our professor has allowed the pin number to be the account number

Same point then. Decide what you want to call it (pin or account), create a descriptive name for the function, and pass it the information it needs.

void PrintTransactionReceipt (int acctNum)
{
  cout << "Account Number : "<< acctNum << endl;
  timeStamp ();
}

Replace any calls to timeStamp () with calls to PrintTransactionReceipt and make sure you pass the account number.

I know this is going to probably make me look like an idiot but I am prepared for it. I have the information set up I thought correctly but still not matching up. When I run it it shows Account #: but nothing after so I am guessing it is just not passing correctly. I will give you the line numbers after sending this...

//Function prototypes
void showMenu();
int mainMenuSelection(int);
void welcomeScreen();
double enterAmountScreen(double);
int anotherTransactionScreen(int);
void goodbyeScreen();
void wait(int);
int dataEntryScreen();
void timeStamp();
void depositTest(double);
void PrintTransactionReceipt(string);
//void withdrawMax();

/*
******************************************************************
******************************************************************
** MAIN FUNCTION                                                 *
** int main function                                             *
******************************************************************
******************************************************************
*/

int main ()
{
    //Declare variables
    int choice;
	string pin;
    
	//Set the numeric output formatting
    cout << fixed << showpoint << setprecision(2);

    //Function for welcome screen
    welcomeScreen();

	//Give space for the function of date and time
	cout << endl << endl;

	//Prompt to show today's date
	cout << "Today's date is: " << endl;

	//Show date and time function
	PrintTransactionReceipt(pin);

	//Enter some space
	cout << endl << endl;

    //Function to enter a pin number
    choice = dataEntryScreen();

	//if statement for choice
	if (choice == -1)

		//Return a value
		return 0;

    //Create a do\while loop
    do
    {
        //Display the menu 
        showMenu();

		//get the user's choice.
        cin >> choice;

        //Validate the menu selection.
        while (choice < 1 || choice > 5)
        {
			//Prompt user to reenter a correct choice
            cout << "Please enter 1, 2, 3, 4, or 5: ";
            cin >> choice;

			//add beep to change in screen
			//add sleep to change in screen
			Beep (440, 500);
			Sleep (500);

			//add color to error message
			//add color to error message
			system ("Color 3a");
        }
        
        //Function to choose in the main menu selection
        mainMenuSelection(choice);

	//End the while statement
    } while (choice != 5);
    
	//Function returns a value
    return 0;
}

void PrintTransactionReceipt (string pin)
{
	cout << "Account Number : " << pin << endl;
	timeStamp ();
}

void timeStamp()
{
	//Calendar time
	 time_t ltime;


	//Get current cal time
	 ltime=time(NULL);

	//Prints out the results
	 printf("%s",asctime( localtime(&ltime) ) );
}

I make the initial call in line 43 and it goes to line 93 and tryin to find a way for the pin number to pass. Thanks for the help.

It's passing fine, but what it's passing is an empty, uninitialized string. pin is declared on line 28, untouched before line 43, then passed on line 43. It looks like you are displaying the pin before you ask the user to type the pin in. In line 48, you have a comment that says "function to enter a pin number", so I imagine that is where it happens. You're printing a transaction receipt before any transaction occurs.

If line 49 is supposed to retrieve the pin number, I don't see where it does so.

//Function to enter a pin number
choice = dataEntryScreen();

If pin is entered here, shouldn't it be:

//Function to enter a pin number
pin = dataEntryScreen();

or better yet,

//Function to enter a pin number
pin = GetPinNumber();

Anyway, your function can only display the correct pin number if that correct pin number has been passed to it, and it can't be passed the correct pin number before that correct pin number has been entered by the user and stored in pin.

Finally, you're either displaying the account number or the pin number. If they are the same thing, they are the same thing, but to avoid confusion, I'd do this:

void PrintTransactionReceipt (string pin)
{
cout << "Pin Number : " << pin << endl;
timeStamp ();
}

or this:

void PrintTransactionReceipt (string acctNum)
{
cout << "Account Number : " << acctNum << endl;
timeStamp ();
}

But you say you are displaying the account number, but you call the variable pin, so it's really confusing. If the account number is always the pin number, I'd drop the pin number altogether.

But that was your problem. You were almost certainly passing an empty string to the function.

Here is what I got now and Ill explain it clearly after I enter this post...

int main ()
{
    //Declare variables
    int choice;
	string pin;
    
	//Set the numeric output formatting
    cout << fixed << showpoint << setprecision(2);

    //Function for welcome screen
    welcomeScreen();

	//Give space for the function of date and time
	cout << endl << endl;

	//Prompt to show today's date
	cout << "Today's date is: " ;

	//Enter current date and time
	timeStamp();

	//Enter some space
	cout << endl << endl;

	//Function to enter a pin number
    pin = dataEntryScreen();

	//Show date and time function
	PrintTransactionReceipt(pin);

	//if statement for choice
	if (choice == -1)

		//Return a value
		return 0;

    //Create a do\while loop
    do
    {
        //Display the menu 
        showMenu();

		//get the user's choice.
        cin >> choice;

        //Validate the menu selection.
        while (choice < 1 || choice > 5)
        {
			//Prompt user to reenter a correct choice
            cout << "Please enter 1, 2, 3, 4, or 5: ";
            cin >> choice;

			//add beep to change in screen
			//add sleep to change in screen
			Beep (440, 500);
			Sleep (500);

			//add color to error message
			//add color to error message
			system ("Color 3a");
        }
        
        //Function to choose in the main menu selection
        mainMenuSelection(choice);

	//End the while statement
    } while (choice != 5);
    
	//Function returns a value
    return 0;
}

int dataEntryScreen()
{
	//Declare variables
	string valid,
		   pin;
	bool found = false;
	int pinChoice,
		i,
		j = 3;
	ifstream Input;

	//Perform do\while loop to check for correct validation
    do
    {
        //Display the output
        cout << "\t\tData Entry Screen";
        cout << endl << "1) Enter pin number";
        cout << endl << "2) Exit the ATM";
        cout << endl << "Please enter a selection: ";
        cin >> pinChoice;

		//add beep to change in screen
		//add sleep to change in screen
		Beep (440, 500);
		Sleep (500);

		//add color to background of data entry screen
		//add color to text of data entry screen
		system ("Color 3c");

		/*
		**********************************************
		**********************************************
		* Check for validation                       *
		* Use while statement                        *
		**********************************************
		**********************************************
		*/

		//Perform while statement
		while (pinChoice < 1 || pinChoice > 2)
        {
			//Enter a correct choice
            cout << "Please reenter 1 or 2: ";
            cin >> pinChoice;

			//add beep to change in screen
			//add sleep to change in screen
			Beep (440, 500);
			Sleep (500);

			//add color to error message
			//add color to error message
			system ("Color 3a");
        }

        //If statement if 2 is selected
        if (pinChoice == 2)
        {
			//exit the atm and returning a value
            return -1;
        }

		//end do\while loop
    } while (pinChoice > 2 || pinChoice < 1);

	/*
	* If statement 1 is selected              
	* Perform for loop                        
	* function to enter pin number
	*/
	for (j = 0; j < 3; j++)
	{
		//Prompt user to enter pin number
		cout << "Please enter your 4 character pin number ";
		cin >> pin;
		
		//Open the file
		Input.open("pin.txt");

		//Perform error test
		if(Input.fail( ))
		{
			//Display error opening file.
			cout << endl << "Error opening input file" << endl;

			//add color to error message
			//add color to error message
			system ("Color 3a");
		}

		//Determine if false
		found = false;

		//Input valid
		Input >> valid;

		//Perform while statement
		while (Input && !found)
		{
			//Perform for loop
			for (i = 0; i < 5; i++)
			{
				//if statement for pin
				if (pin[i] != valid[i])
				i = 6;
			}

			//Determine if true with if statement
			if (i == 5)
			found = true;

			//Perform else statement
			else
			Input >> valid;
		}
		//Skip a line
		cout << endl;

		//Close the file
		Input.close();

		//Clear the file
		Input.clear();

		//If statement if pin number found
		if (found)

			//Return a value
			return 0;

			//Allow only 3 chances for pin to be valid
			if (j < 2)

				//Output for invalid pin number
				cout << endl << "Invalid pin";
				cout << endl << "You have " << 2-j << " more tries" << endl << endl;

				//add color to error message
				//add color to error message
				system ("Color 3a");
	}

	//If statement if pin number is wrong three times
	if (!found)
	{
		//Display output of wrong pin three times
		cout << endl << "Invalid pin";
		cout << endl << "System aborting";
		cout << endl << "Your account has been locked" << endl;

		//Add a pause to the program
		system("pause");

		//add color to error message
		//add color to error message
		system ("Color 3a");

		//Return a value
		return -1;
	

} 
	
//Return a value
	return -1;
}

void timeStamp()
{
	//Calendar time
	 time_t ltime;


	//Get current cal time
	 ltime=time(NULL);

	//Prints out the results
	 printf("%s",asctime( localtime(&ltime) ) );
}

void PrintTransactionReceipt (string pin)
{
	cout << "Account Number : " << pin << endl;
	timeStamp ();
}

I apologize with the pin number looking confusing but our instructor is allowing us to use the pin number as the account number on the time stamp. Here is my issue and I believe it is on line 33. When it runs to this part of the program I get a runtime error and this is not being initialized. I changed this to pin but get the same result. No hurry on this since ive asked a ton of questions with this issue.

I apologize with the pin number looking confusing but our instructor is allowing us to use the pin number as the account number on the time stamp. Here is my issue and I believe it is on line 33. When it runs to this part of the program I get a runtime error and this is not being initialized. I changed this to pin but get the same result. No hurry on this since ive asked a ton of questions with this issue.

Well, choice IS uninitialized. So you enter -1 to exit the program? Is that the idea? I would imagine that lines 32 - 36 should be moved to directly after the user enters choice, which would be line 46.

That would be inside of a loop, so I wouldn't imagine that it would have anything to do with a pin number, since pin numbers are usually asked for once and only once. Your dataEntryScreen() function always returns -1 or 0. I assume 0 means legitimate pin entered and -1 means bad pin entered, so you're not actually returning the pin itself. So you may end up returning something that isn't the pin and calling it "pin".

That's the reason I've been stressing descriptive variable and function names. It should be clear what every function is supposed to return. Make sure it returns what you want it to return.

I have part of the program right. The initial account pin shows up but it does not show after I make a transaction it does not show the account number but I will find that out by playing with it a little bit unless one of you guys know the quick fix but no a major issue. My major issue which I think is the last part of this god in hell program. I am going to post the code and then go into detail about my issue...

//Begin coding the program
#include <iostream>
#include <iomanip>
#include <time.h>
#include <fstream>
#include <conio.h>
#include <string>
#include <windows.h>
 
using namespace std;

//Function prototypes
void showMenu();
int mainMenuSelection(int);
void welcomeScreen();
double enterAmountScreen(double);
int anotherTransactionScreen(int);
void goodbyeScreen();
void wait(int);
int dataEntryScreen(string&);
void timeStamp();
void depositTest(double);
void PrintTransactionReceipt(string);
//void withdrawMax();

/*
******************************************************************
******************************************************************
** MAIN FUNCTION                                                 *
** int main function                                             *
******************************************************************
******************************************************************
*/

int main ()
{
    //Declare variables
    int choice;
	string pin;
    
	//Set the numeric output formatting
    cout << fixed << showpoint << setprecision(2);

    //Function for welcome screen
    welcomeScreen();

	//Give space for the function of date and time
	cout << endl << endl;

	//Prompt to show today's date
	cout << "Today's date is: " ;

	//Enter current date and time
	timeStamp();

	//Enter some space
	cout << endl << endl;

	//Function to enter a pin number
    dataEntryScreen(pin);

	//Show date and time function
	PrintTransactionReceipt(pin);

	//Create a do\while loop
    do
    {
        //Display the menu 
        showMenu();

		//get the user's choice.
        cin >> choice;

		//if statement for choice
		if (choice == -1)

		//Return a value
		return 0;

        //Validate the menu selection.
        while (choice < 1 || choice > 5)
        {
			//Prompt user to reenter a correct choice
            cout << "Please enter 1, 2, 3, 4, or 5: ";
            cin >> choice;

			//add beep to change in screen
			//add sleep to change in screen
			Beep (440, 500);
			Sleep (500);

			//add color to error message
			//add color to error message
			system ("Color 3a");
        }
        
        //Function to choose in the main menu selection
        mainMenuSelection(choice);

	//End the while statement
    } while (choice != 5);
    
	//Function returns a value
    return 0;
}
 
/*
***********************************************************
***********************************************************
* Main Menu Function                                      *
* Function to show the main menu                          *
***********************************************************
***********************************************************
*/

void showMenu()
    {
		//Display the main menu screen
        cout << endl << "\t\tMain Menu Screen" << endl << endl;
        cout << "1) Withdrawal" << endl;
        cout << "2) Deposit" << endl;
        cout << "3) Check Balance" << endl;
        cout << "4) Funds Transfer" << endl;
        cout << "5) Exit ATM" << endl << endl;
        cout << "Please enter a selection: ";

		//add beep to change in screen
		//add sleep to change in screen
		Beep (440, 500);
		Sleep (500);

		//add color to background of main menu screen
		//add color to text of main menu screen
		system ("Color 1a");
	}

/*    
*********************************************************************
*********************************************************************
* Main Menu Screen                                                  *
* Function to choose in the main menu screen                        *
*********************************************************************
*********************************************************************
*/

int mainMenuSelection(int choice)
    {
        //Declare variables in mainMenuSelection
		string pin;
        int withdrawChoice,
            depositChoice,
            checkBalanceChoice,
            fundsTransferChoice;
		double money = 0.0;
		
		//Respond to user's menu selection
        switch (choice)
		{
		//switch case 1
        case 1:

            //Perform do\while loop to check for correct validation
            do
            {
				//let customer know he\she cannot withdraw more than 300 per day
				cout << endl << "You may not withdraw more than $300 for this date:" << endl << endl;

				//function to enter date and time
				PrintTransactionReceipt(pin);

				//give some spaces from main menu
				cout << endl;

                //Show output of function
                cout << endl << "\t\tWithdrawal Screen" << endl << endl;
                cout << "1) From Checking" << endl;
                cout << "2) From Savings" << endl;
                cout << "3) Quick Cash" << endl;
                cout << "4) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> withdrawChoice;

				//add beep to change in screen
				//add sleep to change in screen
				Beep (440, 500);
				Sleep (500);

				//add color to background of withdraw screen
				//add color to text of main menu screen
				system ("Color 6a");

				//While statement to check validation
                while (withdrawChoice < 1 || withdrawChoice > 4)
                {
					//Prompt user to reenter a correct number
                    cout << "Please reenter 1, 2, 3, 4: ";
                    cin >> withdrawChoice;

					//add beep to change in screen
					//add sleep to change in screen
					Beep (440, 500);
					Sleep (500);

					//add color to error message
					//add color to error message
					system ("Color 3a");
                }

				//Perform if statement
                if (withdrawChoice != 4)
                {
					do
					{
					//Function to enter amount screen
                    enterAmountScreen(money);
					
					//Enter a while loop
					while (money > 300)
					{
						//Display error message
						cout << "An error has occurred!" << endl;
						cout << "You have withdrawn more than the max allowed per day!" << endl;
						cout << "Please enter a withdraw amount less than or equal to $300: ";
						cin >> money;

						//add beep to change in screen
						//add sleep to change in screen
						Beep (440, 500);
						Sleep (500);

						//add color to error message
						//add color to error message
						system ("Color 3a");
					}

					//Show the amount withdrawn
					cout << "You have withdrawn $" << money << endl;

					//Perform another while statement
					} while (money > 300);

					//Return the value
                    return -1;
                }
             
			//Complete do\while statement
            } while (withdrawChoice != 4);
            
            //Back to main menu option
            if (withdrawChoice == 4)
            {
				//Return a value
                return -1;
            }

			//Perform a break to go to next case
            break;
		
		//Perform case 2
        case 2:

            //Perform do\while loop to check for correct validation
            do
            {
				//Display output of Deposit Screen
                cout << endl << "\t\tDeposit Screen" << endl << endl;
                cout << "1) To Checking" << endl;
                cout << "2) To Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> depositChoice;

				//add beep to change in screen
				//add sleep to change in screen
				Beep (440, 500);
				Sleep (500);

				//add color to background of withdraw screen
				//add color to text of main menu screen
				system ("Color 6b");
				
				//Check for validation
                while (depositChoice < 1 || depositChoice > 3)
                {
					//Prompt user to enter a correct choice
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> depositChoice;

					//add beep to change in screen
					//add sleep to change in screen
					Beep (440, 500);
					Sleep (500);

					//add color to error message
					//add color to error message
					system ("Color 3a");
                }

				//Perform an if statment
                if (depositChoice !=3)
                {
					//Declare value in function
                    enterAmountScreen(money);

					//Return a value
					return -1;
				}

			//end do\while loop
            } while (depositChoice != 3);

            //Back to main menu option
            if (depositChoice == 3)
            {
				//Return a value
                return -1;
            }

			//Perform a break to go to next case
            break;

		//Prompt to enter case 3
        case 3:

            //Perform do\while loop to check for correct validation
            do
            {
				//Display output
                cout << "\t\tCheck Balance Screen" << endl << endl;
                cout << "1) From Checking" << endl;
                cout << "2) From Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Enter enter a selection: ";
                cin >> checkBalanceChoice;

				//add beep to change in screen
				//add sleep to change in screen
				Beep (440, 500);
				Sleep (500);

				//add color to background of withdraw screen
				//add color to text of main menu screen
				system ("Color 6c");
				
				//Check for validation
                while (checkBalanceChoice < 1 || checkBalanceChoice > 3)
                {
					//Check for validation
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> checkBalanceChoice;

					//add beep to change in screen
					//add sleep to change in screen
					Beep (440, 500);
					Sleep (500);

					//add color to error message
					//add color to error message
					system ("Color 3a");
                }

				//Perform an if statment
                if (checkBalanceChoice !=3)
                {
					//Declare value in function
					cout << endl << "Your balance: $0.00 " << endl;
					return -1;
				}

			//End while statement
            } while (checkBalanceChoice != 3);

            //Back to main menu option
            if (checkBalanceChoice ==3)
            {
				//Return a value
                return -1;
            }

			//Perform break to go to next case
            break;

		//Prompt to begin case 4
        case 4:

            //Perform do\while loop to check for correct validation
            do
            {
				//Display output
                cout << "\t\tFunds Transfer Screen" << endl << endl;
                cout << "1) From Savings to Checking" << endl;
                cout << "2) From Checking to Savings" << endl;
                cout << "3) Back to Main Menu" << endl;
                cout << "Please enter a selection: ";
                cin >> fundsTransferChoice;

				//add beep to change in screen
				//add sleep to change in screen
				Beep (440, 500);
				Sleep (500);

				//add color to background of withdraw screen
				//add color to text of main menu screen
				system ("Color 6d");

				//Check for validation
                while (fundsTransferChoice < 1 || fundsTransferChoice > 3)
                {
					//Prompt user to enter correct selection
                    cout << "Please reenter 1, 2, or 3: ";
                    cin >> fundsTransferChoice;

					//add beep to change in screen
					//add sleep to change in screen
					Beep (440, 500);
					Sleep (500);

					//add color to error message
					//add color to error message
					system ("Color 3a");
                }
                
				//Perform if statement
                if (fundsTransferChoice != 3)
                {
					//Declare values in function
                    enterAmountScreen(money);

					//Return a value
                    return -1;
                }

			//End do while loop
            } while (fundsTransferChoice != 3);

            //Back to main menu option
            if (choice == 3)
            {
				//Return a value
                return -1;
            }

			//Prompt to break to next case
            break;

		//Prompt to enter next case
        case 5:

            //End the program if 5 is selected
            cout << "Program ending." << endl << endl;

			//add beep to change in screen
			//add sleep to change in screen
			Beep (440, 500);
			Sleep (500);

			//add color to background of withdraw screen
			//add color to text of main menu screen
			system ("Color 6e");

			//Perform break
            break;
        }

		//Returns a value
        return 0;
    }

/*
**********************************************************
**********************************************************
* Welcome Screen                                         *
* Function to display the welcome screen                 *
**********************************************************
**********************************************************
*/
void welcomeScreen()
        {
			//add beep to change in screen
			//add sleep to change in screen
			Beep (440, 500);
			Sleep (500);

			//add color to background of the welcome screen
			//add color to test of welcome screen
			system ("Color 3a");

			//Show output of function
            cout << "Hit enter to simulate inserting card";

            //Hit enter to go to the next screen
            cin.get();

		//add beep to change in screen
		//add sleep to change in screen
		Beep (440, 500);
		Sleep (500);

		//add color to background of main menu screen
		//add color to text of main menu screen
		system ("Color 1b");
        }

/*
**********************************************************
**********************************************************
* Enter amount screen                                    *
* Function to enter amount screen                        *
**********************************************************
**********************************************************
*/

double enterAmountScreen(double money)
{
    //Declare function variables
    int decision,
    anotherTransactionChoice = 0;
	string pin;
            
	//prompt user to begin do statemen
	do
	{
		//Show output of function
		cout << endl << "\t\tEnter Amount Screen" << endl;
		cout << "1) Enter an amount:";
		cout << endl << "2) Back to Main Menu:";
		cout << endl << "Please enter a selection: ";
		cin >> decision;

		//add beep to change in screen
		//add sleep to change in screen
		Beep (440, 500);
		Sleep (500);

		//add color to background of enter amount screen
		//add color to text of enter amount screen
		system ("Color 1c");

		/*
		*******************************************
		* Return to main menu option              *
		* Create if statement for decision        *
		*******************************************
		*/

		//Create while statement for decision
		while (decision < 1 || decision > 2)
		{
			//Enter a correct number
			cout << "Please reenter 1 or 2: ";
			cin >> decision;

			//add beep to change in screen
			//add sleep to change in screen
			Beep (440, 500);
			Sleep (500);

			//add color to error message
			//add color to error message
			system ("Color 3a");
		}

		//use an if statement
		if (decision == 2)
		{
			//return a value
			return -1;
		}

		//Perform next if statement
		if (decision == 1)
		{
			//Prompt user to enter the amount
			cout << "Please enter the amount: ";
			cin >> money;
			
			//Enter a depositTest function
			depositTest(money);
		}

		//enter while for a decision
		} while (decision < 1 || decision > 2);
	

		//Perform anotherTransactionScreen function
		anotherTransactionScreen(anotherTransactionChoice);

		//Create a space
		cout << endl;

		//Perform timeStamp function
		PrintTransactionReceipt (pin);
    
	//Return a value
    return money;

}

/*
***********************************************************************
***********************************************************************
* Another Transaction Screen                                          *
* Function to enter another transaction screen                        *
***********************************************************************
***********************************************************************
*/

int anotherTransactionScreen(int anotherTransactionChoice)
{
	//Perform a do statement
    do
    {
		//Display output
        cout << endl << "\t\tAnother Transaction Screen" << endl;
        cout << "1.) Enter another transaction" << endl;
        cout << "2.) Exit the ATM ";
        cout << endl << "Please enter a selection: ";
        cin >> anotherTransactionChoice;

		//add beep to change in screen
		//add sleep to change in screen
		Beep (440, 500);
		Sleep (500);

		//add color to background of another transaction screen
		//add color to text of another transaction screen
		system ("Color 1d");

		/*
		********************************************************************
		********************************************************************
		* Check for validation *
		* Use while statement *
		********************************************************************
		********************************************************************
		*/

		//Perform while statement
		while (anotherTransactionChoice < 1 || anotherTransactionChoice > 2)
		{
			//Enter a correct number
			cout << "Please reenter 1 or 2: ";
			cin >> anotherTransactionChoice;

			//add color to error message
			//add color to error message
			system ("Color 3a");
		}
		//If statement to return to main menu
		if (anotherTransactionChoice == 1)
		{
			//Return a value
			return -1;
		}

		//If statement to display the goodbye screen and exit
		if (anotherTransactionChoice == 2)
		{
			//Go to goodbye function
			goodbyeScreen();

			//Return a value
			return 1;
		}
	
		//end do\while statement
		} while (anotherTransactionChoice == 2 || anotherTransactionChoice == 1);

	//Return a value
	return anotherTransactionChoice;
}

/*
***************************************************************
***************************************************************
* Goodbye Screen                                              *
* Function to display goodbye Screen                          *
***************************************************************
***************************************************************
*/

void goodbyeScreen()
{
    //Declare variables in goodbye screen
    int seconds = 10;

    //Display a goodbye message
    cout << endl << endl << "Have a nice day!" << endl << endl;
    wait(seconds);

	//add beep to change in screen
	//add sleep to change in screen
	Beep (440, 500);
	Sleep (500);

	//add color to background of goodbye screen
	//add color to text of googbye screen
		system ("Color 1f");
}

/*
*****************************************************************
*****************************************************************
* Wait function                                                 *
* Function to wait 10 seconds before returning to main menu     *
*****************************************************************
*****************************************************************
*/

void wait(int seconds)
{
	//Declare variables
    clock_t endwait;

	//Calculate seconds
    endwait = clock () + seconds * CLK_TCK ;

	//Perform while statement for seconds
    while (clock() < endwait) {}
}


/*
***********************************************************
***********************************************************
* Enter pin                                               *
* Function to enter a pin number                          *
***********************************************************
***********************************************************
*/

int dataEntryScreen(string& userpin)
{
	//Declare variables
	string valid,
		   pin;
	bool found = false;
	int pinChoice,
		i,
		j = 3;
	ifstream Input;

	//Perform do\while loop to check for correct validation
    do
    {
        //Display the output
        cout << "\t\tData Entry Screen";
        cout << endl << "1) Enter pin number";
        cout << endl << "2) Exit the ATM";
        cout << endl << "Please enter a selection: ";
        cin >> pinChoice;

		//add beep to change in screen
		//add sleep to change in screen
		Beep (440, 500);
		Sleep (500);

		//add color to background of data entry screen
		//add color to text of data entry screen
		system ("Color 3c");

		/*
		**********************************************
		**********************************************
		* Check for validation                       *
		* Use while statement                        *
		**********************************************
		**********************************************
		*/

		//Perform while statement
		while (pinChoice < 1 || pinChoice > 2)
        {
			//Enter a correct choice
            cout << "Please reenter 1 or 2: ";
            cin >> pinChoice;

			//add beep to change in screen
			//add sleep to change in screen
			Beep (440, 500);
			Sleep (500);

			//add color to error message
			//add color to error message
			system ("Color 3a");
        }

        //If statement if 2 is selected
        if (pinChoice == 2)
        {
			//exit the atm and returning a value
            return -1;
        }

		//end do\while loop
    } while (pinChoice > 2 || pinChoice < 1);

	/*
	* If statement 1 is selected              
	* Perform for loop                        
	* function to enter pin number
	*/
	for (j = 0; j < 3; j++)
	{
		//Prompt user to enter pin number
		cout << "Please enter your 4 character pin number ";
		cin >> userpin;
		
		//Open the file
		Input.open("pin.txt");

		//Perform error test
		if(Input.fail( ))
		{
			//Display error opening file.
			cout << endl << "Error opening input file" << endl;

			//add color to error message
			//add color to error message
			system ("Color 3a");
		}

		//Determine if false
		found = false;

		//Input valid
		Input >> valid;

		//Perform while statement
		while (Input && !found)
		{
			//Perform for loop
			for (i = 0; i < 5; i++)
			{
				//if statement for pin
				if (userpin[i] != valid[i])
				i = 6;
			}

			//Determine if true with if statement
			if (i == 5)
			found = true;

			//Perform else statement
			else
			Input >> valid;
		}
		//Skip a line
		cout << endl;

		//Close the file
		Input.close();

		//Clear the file
		Input.clear();

		//If statement if pin number found
		if (found)

			//Return a value
			return 0;

			//Allow only 3 chances for pin to be valid
			if (j < 2)

				//Output for invalid pin number
				cout << endl << "Invalid pin";
				cout << endl << "You have " << 2-j << " more tries" << endl << endl;

				//add color to error message
				//add color to error message
				system ("Color 3a");
	}

	//If statement if pin number is wrong three times
	if (!found)
	{
		//Display output of wrong pin three times
		cout << endl << "Invalid pin";
		cout << endl << "System aborting";
		cout << endl << "Your account has been locked" << endl;

		//Add a pause to the program
		system("pause");

		//add color to error message
		//add color to error message
		system ("Color 3a");

		//Return a value
		return -1;
	

} 
	
//Return a value
	return -1;
}
	

/*
********************************************************************
********************************************************************
* Enter timestamp                                                  *
* Function to enter timestamp                                      *
********************************************************************
********************************************************************
*/

void timeStamp()
{
	//Calendar time
	 time_t ltime;


	//Get current cal time
	 ltime=time(NULL);

	//Prints out the results
	 printf("%s",asctime( localtime(&ltime) ) );
}

/*
*********************************************************
* Withdraw Max                                          *
* Function to place a limit on                          *
* drawing the max cash                                  *
*********************************************************
*/

//double withdrawMax(double money)
//{
	
//

/*
***********************************************************
* Deposit Test                                            *
* Function to determine if atm has room                   *
* to make a deposit                                       *
***********************************************************
*/

void depositTest(double money)
{
	double depositMoney = money;

	
	//if money is greater than 10000 if statement
	if (depositMoney > 10000)
	{
		//show an error message
		cout << endl << "This ATM has encountered the following error...";
		cout << endl << "This atm has reached the total amount of deposits it can hold.";
		cout << endl << "We apologize for this inconvenience.";
		cout << endl;

		//exit the program if the error occurs
		exit(0);
	}
}

void PrintTransactionReceipt (string pin)
{
	cout << "Account Number : " << pin << endl;
	timeStamp ();
}

ok in line 944 i start a function to test to see and if there is more than 10,000 in deposits in the atm to return an error. It returns an error fine but the same issue occurs when I withdraw more than 10,000. If I need to put more information in just let me know

ok in line 944 i start a function to test to see and if there is more than 10,000 in deposits in the atm to return an error. It returns an error fine but the same issue occurs when I withdraw more than 10,000. If I need to put more information in just let me know

I see nowhere where you ever keep track of how much money is in the ATM. Here's the spec.

8 - Can only hold 10,000 dollars before ATM displays cannot accept any additional deposits.

Your call is in line 578. You pass what the user enters as a deposit, I assume, which has nothing to do with what the total amount in the ATM is. Presumably you're supposed to try to enter $200 51 times and it'll let you do it for the first 50 times, but not the 51st, so you need some way of keeping track of the total amount of money in the ATM. No one is ever going to deposit $10,000 into an ATM in a single transaction, so however you check for this is going to more involved than asking the user for a number and seeing whether it's more than $10,000.

You NEED to go through this entire program and give the variables and functions better names. Otherwise no one, including you, is going to be able to debug this or follow the logic.

commented: Rep for this monster thread +3

I have a quick question with a code I am doing. I am entering a deposit in an atm program and I have an option after the amount is entered to ask the user to enter a new transaction. Anyways what I am trying to do is get the function to accumulate the money so it will return an error if the total deposits for the atm exceed 10000. Here is my code for the function. I have no problem sending the entire code but it is over 1000 lines so if any of you guys can take a look a this without the entire code please let me know

void depositTest(double money)



{

    double depositTotal = 0;

   

   

    while (money <= 10000 && choice == 2)

    {

        depositTotal += money;

    }



   

    //if money is greater than 10000 if statement

    if (money > 10000 && choice == 2)

    {

       

        //show an error message

        cout << endl << "This ATM has encountered the following error...";

        cout << endl << "This atm has reached the total amount of deposits it can hold.";

        cout << endl << "We apologize for this inconvenience.";

        cout << endl;



        //exit the program if the error occurs

        exit(0);

    }

}

I have no problem sending the entire code but it is over 1000 lines so if any of you guys can take a look a this without the entire code please let me know

double depositTotal = 0;

    while (money <= 10000 && choice == 2)
    {
        depositTotal += money;
    }

    //if money is greater than 10000 if statement
    if (money > 10000 && choice == 2)
    {
        //show an error message
        cout << endl << "This ATM has encountered the following error...";

        cout << endl << "This atm has reached the total amount of deposits it can hold.";

        cout << endl << "We apologize for this inconvenience.";
        cout << endl;

        //exit the program if the error occurs
        exit(0);
    }
}

Seeing the entire code is unnecessary. The problem is quite clear. This while loop is a black hole. You can't get out once you get in. It tests for money and money never changes.

  1. Initializing depositTotal to 0 defeats the entire point of the test.
  2. Making depositTotal a local variable defeats the entire point of the test.
  3. There should be no loop.
  4. Any loop should test the variable that changes, not the variable that does not change.
  5. Once again, you are confusing money and depositTotal. That's why you need better variable names. depositTotal is fine. money is not. You need to test depositTotal, not money.
  6. Remind yourself of the entire purpose of the function and walk through the code. Think about what you need to test, pick good variable names, and speak out loud in English what you need to do for each step. If the function is organized properly and the names are well-named, you'll spot exactly where your code does no match what you are saying out loud. If you don't have a pencil and paper as you walk through it, stop and get them. You need to step through with actual values that change. It's a tedious, organized process, and there are no shortcuts. If you are looking at 1000 lines, you are looking at too much. You're debugging the function itself.

I don't have any more time to spend on this. You can start a new thread, but I think your approach needs to be far more focused. I think it may be time for you to look at the overall program and do a re-design. Right now it's very haphazard. Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.