At Westonci.ca, we provide clear, reliable answers to all your questions. Join our vibrant community and get the solutions you need. Our platform offers a seamless experience for finding reliable answers from a network of experienced professionals. Get precise and detailed answers to your questions from a knowledgeable community of experts on our 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
We hope our answers were helpful. Return anytime for more information and answers to any other questions you may have. We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. Thank you for trusting Westonci.ca. Don't forget to revisit us for more accurate and insightful answers.