Hi,
I am having problems with my problem 4.This is what I have as my code. I have 7 compiler errors in it. I don't know how to put the ATM into my program. My project is due wed night
and I am cramming to finish this. But I need a little help
Thanks
Rob
// Author: Robert Dovell
// Source file: Project 4.cpp
//Description: Check Register
//Compiler: Microsoft Visual Studio.NET
#include <iostream.h>
#include "apstring.h"
#include "account.h"
#include "bank.h"
#include <fstream.h>
#include <iomanip.h>
#include <assert.h>
#include "stdafx.h"
using namespace std;
void dep (bank &user, double &amount, apstring savcheck, int savnumber, ofstream &savfile, apstring checknumber, ofstream &checkfile, apstring &payee);
void with (bank &user, double &amount, apstring savcheck, int savnumber, ofstream &savfile, apstring &checknumber, ofstream &checkfile, apstring &payee);
void trans (bank &user, double &amount, apstring savcheck, int savnumber, ofstream &savfile, apstring checknumber, ofstream &checkfile);
void print (bank &user, apstring savcheck);
void inquire (bank &user);
void savings_file (bank &user, int &savnumber, ofstream &savfile, apstring operation, double amount);
void checking_file (bank &user, apstring checknumber, ofstream &checkfile, apstring payee, double amount);
int main ()
{
bool done = 0, back = 0;
bank user;
int choice = 0, savnumber = 0, choice2 = 0;
double amount = 0;
apstring savcheck, payee, checknumber;
ofstream savfile, checkfile;
assert (!savfile.fail());
savfile.open ("savings.txt");
checkfile.open ("checking.txt");
assert (!checkfile.fail());
savfile << "+-------------------+---------------------------+-------------+-------------+\n";
savfile << "|" << setw(16) << "Transaction #" << setw (4) << "|" << setw(22) << "Transaction Type" << setw (6) << "|" << setw (10) << "Amount" << setw (4) << "|" << setw(10) << "Balance" <<setw (5) << "|\n";
savfile << "+-------------------+---------------------------+-------------+-------------+\n";
checkfile << "+-----------+-----------------------------------+-------------+-------------+\n";
checkfile << "|" << setw (9) << "Check #" << setw (3) << "|" << setw (20) << "Payee" << setw (16) << "|" << setw (10) << "Amount" << setw (4) << "|" << setw(10) << "Balance" << setw (5) << "|\n";
checkfile << "+-----------+-----------------------------------+-------------+-------------+\n";
cout << setiosflags (ios::fixed|ios::showpoint);
cout << setprecision (2);
cout << "Welcome to the Ist Mariner Bank!\n";
cout << "\nPlease enter your starting balance (Checking): $";
cin >> amount;
user.deposit (amount, "checking");
checking_file (user, checknumber, checkfile, "Starting Balance", amount);
cout << "Please enter your starting balance (Savings): $";
cin >> amount;
user.deposit (amount, "savings");
savings_file (user, savnumber, savfile, "Starting Balance", amount);
savnumber++;
amount = user.goto_interest ();
cout << "You earned $" << amount << " interest this month.\n";
user.deposit (amount, "savings");
cout << "Your current savings balance is: $" << user.print_savings ();
savings_file (user, savnumber, savfile, "Interest", amount);
savnumber++;
while (! done)
{
cout << "\n\n\t1. Checking\n";
cout << "\t2. Savings\n";
cout << "\t0. Quit\n";
cout << "\nPlease enter which account you want to use: ";
cin >> choice;
switch (choice)
{
case 1 : savcheck = "Checking";
back = 0;
break;
case 2 : savcheck = "Savings";
back = 0;
break;
case 0 : done = 1;
back = 1;
break;
default : cout << "You entered an invalid entry, please reconsider it.\n";
break;
}
while (! back)
{
cout << "\n\t1. Deposit\n";
cout << "\t2. Withdrawal\n";
cout << "\t3. Transfer\t\t\t\tYou are in your\n";
cout << "\t4. Print Balances\t\t\t" << savcheck << " acount\n";
cout << "\t0. Return to previous menu\n";
cout << "\nSelect amount transaction: ";
cin >> choice2;
cout << endl;
switch (choice2)
{
case 1 : dep (user, amount, savcheck, savnumber, savfile, checknumber, checkfile, payee);
if (savcheck == "Savings" || savcheck == "savings") savnumber++;
print (user, savcheck);
break;
case 2 : with (user, amount, savcheck, savnumber, savfile, checknumber, checkfile, payee);
if (savcheck == "Savings" || savcheck == "savings") savnumber++;
print (user, savcheck);
break;
case 3 : trans (user, amount, savcheck, savnumber, savfile, checknumber, checkfile);
savnumber++;
print (user, savcheck);
break;
case 4 : inquire (user);
break;
case 0 : back = 1;
break;
default : cout << "You entered an invalid entry, please reconsider it.\n";
break;
}
}
}
cout << "\nThank you for using the Williston Bank!\n";
cout << "You can access the data to your accounts using amount wordprocessor.\n";
cout << "The file names are: 'savings.txt' and 'checking.txt'\n\n";
savfile << "+-------------------+---------------------------+-------------+-------------+";
checkfile << "+-----------+-----------------------------------+-------------+-------------+";
return 0;
}
void dep (bank &user, double &amount, apstring savcheck, int savnumber, ofstream &savfile, apstring checknumber, ofstream &checkfile, apstring &payee)
//This function will ask the user for the amount that should be deposited and deposits it to the right account
{
cout << "Please enter the amount of money you want to deposit: $";
cin >> amount;
if (savcheck == "Checking" || savcheck == "checking")
{
if (amount >= 0)
{
user.deposit (amount, savcheck);
checking_file (user, checknumber, checkfile, "Deposit", amount);
}
else cout << "You entered an invalid entry, please reconsider it.\n";
}
else
{
if (amount >= 0)
{
user.deposit (amount, savcheck);
savings_file (user, savnumber, savfile, "Deposit", amount);
}
else cout << "You entered an invalid entry, please reconsider it.\n";
}
}
void with (bank &user, double &amount, apstring savcheck, int savnumber, ofstream &savfile, apstring &checknumber, ofstream &checkfile, apstring &payee)
//This function will ask the user for the amount that should be withdrawn and withdraws it from the right account
{
cout << "Please enter the amount of money you want to withdraw: $";
cin >> amount;
getline (cin, payee);
if (savcheck == "Checking" || savcheck == "checking")
{
if (amount <= user.print_checking())
{
user.withdraw (amount, savcheck);
cout << "Please enter the checknumber: ";
getline (cin, checknumber);
cout << "Please enter whose order the check should be paid to: ";
getline (cin, payee);
checking_file (user, checknumber, checkfile, payee, amount);
}
else cout << "You entered an invalid entry, please reconsider it.\n";
}
else
{
if (amount <= user.print_savings())
{
user.withdraw (amount, savcheck);
savings_file (user, savnumber, savfile, "Withdrawal", amount);
}
else cout << "You entered an invalid entry, please reconsider it.\n";
}
}
void trans (bank &user, double &amount, apstring savcheck, int savnumber, ofstream &savfile, apstring checknumber, ofstream &checkfile)
//This function will ask the user from which account he/she wants to transfer and the amount that should be transfered
{
cout << "Please enter the amount of money you want to transfer: $";
cin >> amount;
if (savcheck == "Checking" || savcheck == "checking")
{
if (amount <= user.print_checking())
{
user.transfer (amount, savcheck);
savings_file (user, savnumber, savfile, "Transf from Checking", amount);
checking_file (user, " ", checkfile, "Transf to Savings", amount);
}
else cout << "You entered an invalid entry, please reconsider it.\n";
}
else
{
if (amount <= user.print_savings())
{
user.transfer (amount, savcheck);
savings_file (user, savnumber, savfile, "Transf to Checking", amount);
checking_file (user, " ", checkfile, "Transf from Savings", amount);
}
else cout << "You entered an invalid entry, please reconsider it.\n";
}
}
void print (bank &user, apstring savcheck)
//This function prints the balance of either the checking or the savings account
{
if (savcheck == "Checking" || savcheck == "checking")
cout << "Current Checking balance: $" << user.print_checking () << endl;
else
cout << "Current Savings balance: $" << user.print_savings () << endl;
}
void inquire (bank &user)
//This function pritns out the balances for both accounts
{
cout << "Current Checking balance: $" << user.print_checking () << endl;
cout << "Current Savings balance: $" << user.print_savings () << endl;
}
void savings_file (bank &user, int &savnumber, ofstream &savfile, apstring operation, double amount)
//This function will output all the savings account transactions to amount text file "savings.txt"
{
savfile << "|" << setw (10) << savnumber << setw (10) << "|" << setw (22) << operation << setw (6) << "|" << setw (10) << amount << setw (4) << "|" << setw (10) << user.print_savings () << setw (5) << "|\n";
}
void checking_file (bank &user, apstring checknumber, ofstream &checkfile, apstring payee, double amount)
//This function will output all the checking account transactions to amount text file "checking.txt"
{
checkfile << "|" << setw (6) << checknumber << setw (6) << "|" << setw (26) << payee << setw (10) << "|" << setw (8) << amount << setw (6) << "|" << setw (8) << user.print_checking () << setw (7) << "|\n";
}