Question
Problem Description In this assignment, you will be writing a C++ program for ATM machines to serve multiple customers. Each customer has a Personal Identification
Problem Description
In this assignment, you will be writing a C++ program for ATM machines to serve multiple customers. Each customer has a Personal Identification Number (PIN), and there are two types of customers. Type 1 customers have an odd PIN number and type 2 customers have an even PIN number. A type 2 customer will be charged $5 if the amount requested makes the balance fall below $500. A customer can process multiple withdrawals in a session. To end a session, the customer will enter a -1.
Input
At the beginning of the program, the customers balance is entered into the system.
Each customer will enter her/his PIN number and the amount they want to withdraw. The balance in the account must always be enough to cover the withdrawal plus any fees. If a fee is to be charged for a withdrawal amount, and there is not enough in the balance to cover the and the withdrawal amount, it should print, "Not enough money in your account to pay the fee!. See the Sample Runs for an example.
All PIN numbers are between 1000 and 9999, inclusive. If an entered PIN number is out of the range, then the program shall display a message and ask the customer to enter a PIN again until a valid PIN number is entered. Once a valid pin is entered, the program will run until the user enters a -1 to quit, or if the balance is zero.
The amount a customer may request is between $20 and $1000, inclusive. If an entered amount is out of the range, the program shall display a message and ask the customer to enter another amount again until a valid amount is entered. The withdrawal amount must be divisible by 5, as the smallest denomination that the ATM dispenses is a $5 bill. The balance in the account must be enough to cover the withdrawal.
If a type 2 customer enters a withdrawal amount that makes the balance fall below $500, the program shall display a message to warn the customer of the $5 fee. The balance in the account must be enough to cover the withdrawal and the fee. If there is not enough money in the balance, the withdrawal will not be processed.
In all cases, the withdrawal amount must not exceed the balance.
Output
After processing a valid request, the program shall display the amount requested, the fee if applicable, and the bills the customer is receiving. The ATM can deliver $20, $10, and $5 bills, and the machine will deliver the maximum possible number of $20 bills, one $10 bill if the remaining is at least 10, and one $5 bill if the remaining is at least 5. The customer enters a -1 to quit. The program shall display messages to assist customers to use the ATM. See the sample run later for details and formats of the output.
Pseudocode
Read in balance
Read in and validate PIN
Read in amount to be withdrawn, loop until -1
Validate withdrawl amount
If type 2 customer
Print Fee message
If not enough money with fee, print error
If there is enough money
Subtract withdrawl from amount
Subtract fee if type 2
Print withdrawl amount
Dispense money
Read in amount to be withdrawn
Notes
As a minimal output and to receive credit for doing program 2, your program MUST get the correct output for Test Case 1.
Each sentinel-controlled loop must be primed.
Follow the output format exactly.
Remember you cannot have magic numbers in your program.
Sample run (Test Case 1) responses in red are the users typed responses
Enter your balance: 1000
Enter your PIN: 0
Invalid PIN: 0.
Enter your PIN: 10
Invalid PIN: 10.
Enter your PIN: 100
Invalid PIN: 100.
Enter your PIN: 1000
Your balance is $1000.
Enter the amount to be withdrawn, -1 to quit: 99
Invalid amount: 99.
Your balance is $1000.
Enter the amount to be withdrawn: 500
You requested $500.
You are receiving the following bills:
Number of $20 bills: 25
Number of $10 bills: 0
Number of $5 bills: 0
Enter the amount to be withdrawn, -1 to quit: 150
You are a type 2 customer, but the withdrawal
amount you requested makes your balance $350,
which is below the minimum balance required.
You will be charged $5.
You requested $150.
You are receiving the following bills:
Number of $20 bills: 7
Number of $10 bills: 1
Number of $5 bills: 0
Your balance is $345.
Enter the amount to be withdrawn, -1 to quit: -1
Thank you for banking with us, have a nice day!
Sample run (Test Case 2)
Enter your balance: 300
Enter your PIN: 9997
Your balance is $300.
Enter the amount to be withdrawn, -1 to quit: 202
Invalid amount: 202.
Your balance is $300.
Enter the amount to be withdrawn: 200
You requested $200.
You are receiving the following bills:
Number of $20 bills: 10
Number of $10 bills: 0
Number of $5 bills: 0
Your balance is $100.
Enter the amount to be withdrawn, -1 to quit: 2000
Invalid amount: 2000.
Your balance is $100.
Enter the amount to be withdrawn: 100
You requested $100.
You are receiving the following bills:
Number of $20 bills: 5
Number of $10 bills: 0
Number of $5 bills: 0
Your balance is $0.
Enter the amount to be withdrawn, -1 to quit: -1
Thank you for banking with us, have a nice day!
Sample run (Test Case 3)
Enter your balance: 200
Enter your PIN: 1100
Your balance is $200.
Enter the amount to be withdrawn, -1 to quit: 300
Invalid amount: 300.
Your balance is $200.
Enter the amount to be withdrawn: 400
Invalid amount: 400.
Your balance is $200.
Enter the amount to be withdrawn: 200
You are a type 2 customer, but the withdrawal
amount you requested makes your balance $0,
which is below the minimum balance required.
You will be charged $5.
Not enough in your account to cover the withdrawal and the fee!
Your balance is $200.
Enter the amount to be withdrawn, -1 to quit: 400
Invalid amount: 400.
Your balance is $200.
Enter the amount to be withdrawn: 100
You are a type 2 customer, but the withdrawal
amount you requested makes your balance $100,
which is below the minimum balance required.
You will be charged $5.
You requested $100.
You are receiving the following bills:
Number of $20 bills: 5
Number of $10 bills: 0
Number of $5 bills: 0
Your balance is $95.
Enter the amount to be withdrawn, -1 to quit: 200
Invalid amount: 200.
Your balance is $95.
Enter the amount to be withdrawn: 50
You are a type 2 customer, but the withdrawal
amount you requested makes your balance $45,
which is below the minimum balance required.
You will be charged $5.
You requested $50.
You are receiving the following bills:
Number of $20 bills: 2
Number of $10 bills: 1
Number of $5 bills: 0
Your balance is $40.
Enter the amount to be withdrawn, -1 to quit: -1
Thank you for banking with us, have a nice day!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started