Please i need the code of a simple ATM program on C, please help me!!!

// ATM.cpp
 2  // Member-function definitions for class ATM.
 3  #include "ATM.h" // ATM class definition
 4  #include "Transaction.h" // Transaction class definition
 5  #include "BalanceInquiry.h" // BalanceInquiry class definition
 6  #include "Withdrawal.h" // Withdrawal class definition
 7  #include "Deposit.h" // Deposit class definition
 8
 9  // enumeration constants represent main menu options
10  enum MenuOption { BALANCE_INQUIRY = 1, WITHDRAWAL, DEPOSIT, EXIT };
11
12  // ATM default constructor initializes data members
13  ATM::ATM()
14     : userAuthenticated ( false ), // user is not authenticated to start
15       currentAccountNumber( 0 ) // no current account number to start
16  {
17     // empty body
18  } // end ATM default constructor
19
20  // start ATM
21  void ATM::run()
22  {
23     // welcome and authenticate user; perform transactions
24     while ( true )
25     {
26        // loop while user is not yet authenticated
27        while ( !userAuthenticated )
28        {
29           screen.displayMessageLine( "\nWelcome!" );
30           authenticateUser(); // authenticate user
31        } // end while
32
33        performTransactions(); // user is now authenticated
34        userAuthenticated = false; // reset before next ATM session
35        currentAccountNumber = 0; // reset before next ATM session
36        screen.displayMessageLine( "\nThank you! Goodbye!" );
37     } // end while 
38  } // end function run
39
40  // attempt to authenticate user against database
41  void ATM::authenticateUser()
42  {
43     screen.displayMessage( "\nPlease enter your account number: " );
44     int accountNumber = keypad.getInput(); // input account number
45     screen.displayMessage( "\nEnter your PIN: " ); // prompt for PIN
46     int pin = keypad.getInput(); // input PIN
47
48     // set userAuthenticated to bool value returned by database
49     userAuthenticated =
50        bankDatabase.authenticateUser( accountNumber, pin );
51
52     // check whether authentication succeeded
53     if ( userAuthenticated )
54     {
55        currentAccountNumber = accountNumber; // save user's account #
56     } // end if
57     else
58        screen.displayMessageLine(
59           "Invalid account number or PIN. Please try again." );
60  } // end function authenticateUser
61
62  // display the main menu and perform transactions
63  void ATM::performTransactions()
64  {
65     // local pointer to store transaction currently being processed
66     Transaction *currentTransactionPtr;
67
68     bool userExited = false; // user has not chosen to exit
69
70     // loop while user has not chosen option to exit system
71     while ( !userExited )
72     {
73        // show main menu and get user selection
74        int mainMenuSelection = displayMainMenu();
75
76        // decide how to proceed based on user's menu selection
77        switch ( mainMenuSelection )
78        {
79           // user chose to perform one of three transaction types
80           case BALANCE_INQUIRY:
81           case WITHDRAWAL:
82           case DEPOSIT:
83              // initialize as new object of chosen type
84              currentTransactionPtr =
85                 createTransaction( mainMenuSelection );
86
87              currentTransactionPtr->execute(); // execute transaction
88
89              // free the space for the dynamically allocated Transaction
90              delete currentTransactionPtr;
91
92              break;
93           case EXIT: // user chose to terminate session
94              screen.displayMessageLine( "\nExiting the system..." );
95              userExited = true; // this ATM session should end
96              break;
97           default: // user did not enter an integer from 1-4
98              screen.displayMessageLine(
99                 "\nYou did not enter a valid selection. Try again." );
100             break;
101       } // end switch
102     } // end while
103  } // end function performTransactions
104
105  // display the main menu and return an input selection
106  int ATM::displayMainMenu() const
107  {
108     screen.displayMessageLine( "\nMain menu:" );
109     screen.displayMessageLine( "1 - View my balance" );
110     screen.displayMessageLine( "2 - Withdraw cash" );
111     screen.displayMessageLine( "3 - Deposit funds" );
112     screen.displayMessageLine( "4 - Exit\n" );
113     screen.displayMessage( "Enter a choice: " );
114     return keypad.getInput(); // return user's selection
115  } // end function displayMainMenu
116
117  // return object of specified Transaction derived class
118  Transaction *ATM::createTransaction( int type )
119  {
120     Transaction *tempPtr; // temporary Transaction pointer
121
122     // determine which type of Transaction to create 
123     switch ( type )
124     {
125        case BALANCE_INQUIRY: // create new BalanceInquiry transaction
126           tempPtr = new BalanceInquiry(
127              currentAccountNumber, screen, bankDatabase );
128           break;
129        case WITHDRAWAL: // create new Withdrawal transaction
130           tempPtr = new Withdrawal( currentAccountNumber, screen,
131              bankDatabase, keypad, cashDispenser );
132           break;
133        case DEPOSIT: // create new Deposit transaction
134           tempPtr = new Deposit( currentAccountNumber, screen,
135              bankDatabase, keypad, depositSlot );
136           break;
137     } // end switch
138
139     return tempPtr; // return the newly created object
140  } // end function createTransaction
commented: Is this an answer to the question? If so, shame! We don't do homework for people. -- Is this a question? If so, shame! What's the question and why hijack someone's thread? -2
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.