The output file stream will be coded as such
ofstream output_file;
output_file.open("Ch4_Ex15_Output.txt", ios::out);
output_file << balance;
input.close();
output_file.close();
return 0;
}
<h3>
Output file stream</h3>
Generally, Given the instructions we see that the program will "output account balance before and after withdrawal and service charges"
Therefore we must conclude at the output file stream bearing all information required.
double withdraw(double balance) {
cout << "Current Balance in the account: " << balance << endl;
if(balance <= 0) {
cout << "Insufficent balance" << endl;
return balance;
}
double withdraw;
cout << "Amount of money for withdraw: "; cin >> withdraw;
if(withdraw > 500) {
cout << "$500 per day can be withdrawn!";
return balance;
}
double charge = 0;
if(balance >= withdraw) {
balance -= withdraw;
charge = (withdraw <= 300) ? 0 : (withdraw - 300) * 0.04;
}
else {
char option;
cout << "Insufficient funds! Service charged $25, Want to withdraw money?(Y/N): ";
cin >> option;
if(option == 'Y' || option == 'y') {
balance -= withdraw;
charge = 25;
}
}
balance -= charge;
cout << "balance after Withdraw: " << balance << endl;
cout << "charge for transaction: " << charge << endl;
return balance;
}
int main() {
ifstream input;
input.open("Ch4_Ex15_Data.txt", ios::in);
double balance;
input >> balance;
balance = withdraw(balance);
ofstream output_file;
\therefore the output stream is
output_file.open("Ch4_Ex15_Output.txt", ios::out);
output_file << balance;
input.close();
output_file.close();
return 0;
}
More on Algorithm
brainly.com/question/11623795