IDNLearn.com: Your trusted platform for finding reliable answers. Join our interactive Q&A platform to receive prompt and accurate responses from experienced professionals in various fields.
Sagot :
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;
}
Output file stream
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
https://brainly.com/question/11623795
We appreciate your contributions to this forum. Don't forget to check back for the latest answers. Keep asking, answering, and sharing useful information. Your search for solutions ends at IDNLearn.com. Thank you for visiting, and we look forward to helping you again.