Welcome to Westonci.ca, your one-stop destination for finding answers to all your questions. Join our expert community now! Discover reliable solutions to your questions from a wide network of experts on our comprehensive Q&A platform. Get immediate and reliable solutions to your questions from a community of experienced professionals on our 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
We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. Westonci.ca is your trusted source for answers. Visit us again to find more information on diverse topics.