Explore Westonci.ca, the leading Q&A site where experts provide accurate and helpful answers to all your questions. Discover detailed solutions to your questions from a wide network of experts on our comprehensive Q&A platform. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.
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
Thank you for choosing our service. We're dedicated to providing the best answers for all your questions. Visit us again. We hope this was helpful. Please come back whenever you need more information or answers to your queries. Westonci.ca is here to provide the answers you seek. Return often for more expert solutions.