You are on page 1of 2

#include <fstream>

#include <iostream>

using namespace std;

int main()
{
int account_number = 0;
cout << "ENTER YOUR ACCOUNT NUMBER" << endl;
cin >> account_number;
ofstream output;
output.open("test.txt");
output << account_number << " ";
char type = 'r';
cout << "ENTER YOUR ACCOUNT TYPE" << endl;
cin >> type;
output << type << " ";
double minimum = 0;
cout << "ENTER YOUR MINIMUM BALANCE " << endl;
cin >> minimum;
output << minimum << " ";
double balance = 0;
cout << "ENTER YOUR BALANCE " << endl;
cin >> balance;
output << balance << " ";
output.close();

ifstream input;
input.open("test.txt");
int s1 = 0;
char s2 = 'f';
double s3 = 0;
double s4 = 0;
if (input >> s1 >> s2 >> s3 >> s4) {
cout << "Account number is "<< s1 << endl;
if (s2 == 'c')
{
cout << "ACCOUNT TYPE " << "CURRENT" << endl;
}
if (s2 == 's')
{
cout << "ACCOUNT TYPE " << "SAVINGS" << endl;
}
}
else {
cout << "ERROR: Failed to read input file." << endl;
}
input.close();
double interest;
if (s2 == 's')
{
if (s3 > s4) {
s4 = s4 - 10;
cout << "YOU FAILED TO MEET THE MINIMUM BALANCE" << endl;
cout << "YOUR SERVICE CHARGES ARE " << " $ 10 " << endl;
cout << "CURRENT BALANCE " << s4 << endl;
}
if (s4 > s3)
{
interest = s4 * 0.04;
cout << "YOU RECIEVED INTEREST " << "$ " << interest << endl;
cout << "YOUR NEW BALANCE IS " << " $ " << s4 + interest << endl;
}
}
if (s2 == 'c')
{
if (s3 > s4)
{
s4 = s4 - 25;
cout << "YOU FAILED TO MEET THE MINIMUM BALANCE" << endl;
cout << "YOUR SERVICE CHARGES ARE " << " $ 10 " << endl;
cout << "CURRENT BALANCE " << s4 << endl;
}
if (s4 > s3)
{
if (s4 - s3 > 5000)
{
interest = 0.05 * s4;
cout << "YOU RECIEVED INTEREST " << "$ " << interest << endl;
cout << "YOUR NEW BALANCE IS " << " $ " << s4 + interest << endl;
}
if (s4 - s3 < 5000)
{
interest = 0.03 * s4;
cout << "YOU RECIEVED INTEREST " << "$ " << interest << endl;
cout << "YOUR NEW BALANCE IS " << " $ " << s4 + interest << endl;
}
}
}
return 0;
}

You might also like