I can make this program with the basic functions, but when I need to add all of these extra things I get very confused and do not know where to start. When I start writing the code I find a dead end and start over, and over, and over. Right now I am trying to figure out how to start where they enter there name, and pin, and once this is validated do I start two separate functions with the same code to save that specific persons info? or is there a way to write information in a file for each person in one function?
"
You have been hired by a new bank in the area to write an ATM program. The bank currently has 2 customers, Joey whose PIN number is 4433 and has a current balance of $3742.55 in his account and Mildred who currently has $19.36 in her account. Her PIN number is 2849. Your program should handle the following conditions.
Program should prompt the user for their name. Once the name has been verified, the user has up to 3 chances to enter the correct PIN number.
Once all verifications are done, the program should allow the user to do the following:
Check balance - display current balance
Withdraw money – check to make sure the account has the requested funds. Do not allow negative balances. Display the new balance.
Make a deposit – display new balance. Accounts with balances over $4500 receive a 3% cash reward added to their account.
User should be restricted to performing 2 transactions at a time.
The ATM “closes for the night” when the user enters END for the name. Final balances for each user should be displayed.
The name, PIN number and final balance for the customers should be written to a file named “Customers.dat”
Don’t forget:
NO GLOBAL variables.
All of the above should be implemented with functions. Other functions should be implemented where possible to create an efficient program.
Avoid duplicated code.
Break, continue and return statements should not be implemented within if statements
Output should be labeled, aligned, and formatted to 2 decimal places. "
*** I am not looking for you to write the code for me, just some hints to get started, so please do not respond with this. ***
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
cccc#include <iostream>
#include <iomanip>
#include <string> //include string for user name
#include <fstream> // file to save each users information
using namespace std;
void getName(string);
void getPin(int,int);
void displayMenu(int);
string name;
int pin1, pin2, choice;
int main()
{
// set output formatting
cout << fixed << showpoint << setprecision(2);
getName(name);
getPin(pin1,pin2);
displayMenu(choice);
system("pause");
}
//************************************************************************
//************************************************************************
void getName(string name)
{
cout << "Enter your name: ";
cin >> name;
if (name = "Joey Stowy") || (name != "Mildred Moredebt"))
{
getName(name);
}
}
//*************************************************************************
//*************************************************************************
void getPin(int pin1, int pin2)
{
string name;
if (name == "Joey Stowy")
{
cout << "Please Enter Pin: ";
cin >> pin1;
if (pin1 != 4433)
{
cout << "Pin incorrect please try again!";
cin >> pin1;
}
}
if (name == "Mildred Moredebt")
{
cout << "Please Enter Pin: ";
cin >> pin2;
if (pin2 != 2849)
{
cout << "Pin incorrect please try again!";
cin >> pin2;
}
}
}
//*************************************************************************
//*************************************************************************
void displayMenu(int choice)
{
cout << "[1] Check your account Balance\n"
"[2] Withdraw funds\n"
"[3] Deposit funds\n"
"Please Enter Choice: ";
cin >> choice;
if (choice != 1 || choice != 2 || choice != 3)
{
cout << "Choice is incorrect, enter choice now: ";
cin >> choice;
}
}
|