Question: C programming question C programming question Write a simple ATM machine program. Initialize four variables to hold the account number (a 10-digit number), the name
C programming question
C programming question
Write a simple ATM machine program.
Initialize four variables to hold the account number (a 10-digit number), the name of the account holders name (the variable should be able to hold names up to 25 characters in length), the passcode (a 6-digit number), and the balance of a bank account. Normally this information would be stored in a database in the banks computer and the program would retrieve the information from the database. However, youll just choose values for testing and initialize the variables to these values. Create another two variables to hold the values that the user will enter for account number and passcode. Determine what would be the best data type for each of these variables (Choose from the following: char, int, short, long long, float, double, and string/character array).
Your program should display a message indicating that this is an ATM. You can name the bank. Ex: Welcome to Rainbow Banks ATM.
Next the program should prompt the bank customer for their account number. If the account number matches the stored account number, you should prompt them to enter their passcode. If it doesnt, display an appropriate error message. Ex: Error: Invalid account number and the program should exit.
If the account number and passcode are correct, display a welcome message. Ex: Welcome Joe, how can I help you today? (Assuming the account holders name is Joe). If the passcode is incorrect, display an appropriate error message and then exit the program.
Next, give the bank customer three options.
Ex: 1 Check account balance.
2 Deposit cash. 3 Withdraw cash. Please specify your selection :
If the customer selects 1, display the account balance.
If the customer selects 2, ask the customer how much they would like to deposit, add it to the
account balance, and display the new balance.
If the customer selects 3, ask how much the customer wants to withdraw and check to see if there is enough money. If there isnt, tell the customer that they do not have enough money and exit. If there is enough money, subtract the amount withdrawn from the balance and display the new balance.
If the customer puts in a choice other than 1, 2 or 3, print an error message (Ex: Invalid selection) and exit the program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
