-----------
A bank updates t customers'' accounts at the end of each month. The bank offers two types of accounts: savings and checking. Every customer must maintain a minimum balance. If a customer's balance falls below the minimum balance, there is a service charge of $10.00 for savings accounts and $25.00 for checking accounts. If the balance at the end of the month is at least the minimum balance, the account receives interest as follows:
a) Savings accounts receive 4% interest.
I have tested my logarithm based on user input but now im trying with a input file and export calculations to output file...following is my code
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
// Declare Variables and Strings
string source;
string sourceout;
string acctNumber;
char acctType;
double begBalance;
double acctBalance;
double interest;
double minimumBalance;
double serv;
//fstream variables
ifstream infile;
ofstream outfile;
cout<<"Welcome To The Banking Program"<<endl;
cout<< "Please enter your source file for calculations: (ie. 'source.dat' " << endl;
getline(cin,source);
cout<<endl;
infile.open(source.c_str()); //cannot locate source program ends
if (!infile)
{
cout<<"Unable to locate the source file"<<endl;
cout<<"Program Terminates"<<endl;
return 1;
}
infile>>acctNumber>>acctType>>minimumBalance>>begBalance;
infile.close();
if (acctType == 'S' && begBalance < minimumBalance)
{acctBalance = begBalance - 10.00,serv = 10.00;}
if (acctType == 'C' && begBalance < minimumBalance)
{acctBalance = begBalance - 25.00,serv = 25.00;}
if (acctType == 'S' && begBalance > minimumBalance)
{interest = (begBalance * 4)/100;}
if (acctType == 'C' && begBalance <= (minimumBalance + 5000.00) && begBalance > minimumBalance)
{interest = (begBalance * 3)/100;}
if (acctType == 'C' && begBalance >= minimumBalance)
{interest = (begBalance * 5)/100;}
////////////////////////////////////////////////////////////////////////////////////////////////////
cout<< "Please enter name for your out file: (ie. 'sourceout.dat') " << endl;
getline(cin,sourceout);
outfile.open(sourceout.c_str());
outfile<<acctBalance<<interest<<serv;
cout<< endl<< endl
<< "account acount beginning intrest service ending" <<endl
<< "number type balance earned fee balance"<<endl
<< "--------------------------------------------------------------------"<<endl;
cout<<fixed<<showpoint;
cout<<setprecision(2);
cout<<acctNumber<<" "<<acctType<<" "<<begBalance<<" "
<<interest<<" "<<serv<<" "<<acctBalance<<endl;
outfile.close();
im gettting errors about interest serv and acctBalance not being initialized
also how do i get the program to read and output until eof.... both on screen and in outfile
any help is greatly apperciated,,, im attaching the in.dat, and the out.dat,,,
lmk wats up
ok the attachments didnt work
heres in.dat
00001 s 1000 1040
00002 c 1500 1545
00003 c 2000 4892.5
00004 c 1500 7350
00005 s 1000 980
00006 s 1000 2808
00007 c 1500 1225
46728 s 1000 2808
87324 c 1500 8073.45
79893 s 1000 790
89832 c 2000 3090
98322 c 1000 725
A3790 s 1500 2000
A3791 s 1500 1450
B3792 c 1500 1510
B3793 c 1500 1409
B2794 c 1500 6510
and out.dat
acct acct Begining interest service current
num type balance added fee balance
-----------------------------------------------------------------
00001 s $ 1040.00 $ 41.60 $ 0.00 $ 1081.60
00002 c $ 1545.00 $ 46.35 $ 0.00 $ 1591.35
00003 c $ 4892.50 $ 146.78 $ 0.00 $ 5039.27
00004 c $ 7350.00 $ 367.50 $ 0.00 $ 7717.50
00005 s $ 980.00 $ 0.00 $ 10.00 $ 970.00
00006 s $ 2808.00 $ 112.32 $ 0.00 $ 2920.32
00007 c $ 1225.00 $ 0.00 $ 25.00 $ 1200.00
46728 s $ 2808.00 $ 112.32 $ 0.00 $ 2920.32
87324 c $ 8073.45 $ 403.67 $ 0.00 $ 8477.12
79893 s $ 790.00 $ 0.00 $ 10.00 $ 780.00
89832 c $ 3090.00 $ 92.70 $ 0.00 $ 3182.70
98322 c $ 725.00 $ 0.00 $ 25.00 $ 700.00
A3790 s $ 2000.00 $ 80.00 $ 0.00 $ 2080.00
A3791 s $ 1450.00 $ 0.00 $ 10.00 $ 1440.00
B3792 c $ 1510.00 $ 45.30 $ 0.00 $ 1555.30
B3793 c $ 1409.00 $ 0.00 $ 25.00 $ 1384.00
B2794 c $ 6510.00 $ 325.50 $ 0.00 $ 6835.50

New Topic/Question
Reply




MultiQuote


|