Calculate Bank Charges Help
Feb 4, 2014 at 11:56pm UTC
This is an simple program that is supposed to prompt the user for the beginning balance and the number of checks written and then compute the service fee for that month. My program runs fine, but it is supposed to add 15$ when the beginning balance is less than 400$. I think the problem is with my equation at the start and probably at the end when I'm trying to calculate the total. I have messed around with it but I can't seem to figure it out. Any insight would be greatly appreciated. I also forgot to mention that the permonth = 10 is the monthly charge that needs to be included. That works fine I just wanted to clarify what it was since it needs to be in the final equation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float beginning_balance, servicefee, checkfees;
float permonth = 10;
int checks_processed;
int fee = 15;
if ( beginning_balance < 400)
+ fee;
cout << "Enter beginning balance: " ;
cin >> beginning_balance;
cout << "Enter number of checks processed: " ;
cin >> checks_processed;
if ( checks_processed < 20)
{
checkfees = .10 * checks_processed;
}
else if ( checks_processed > 20)
{
checkfees = .08 * checks_processed;
}
servicefee = ( permonth + checkfees);
cout << "\nThe service fee for the month is $ " << servicefee;
return 0;
}
Feb 5, 2014 at 12:14am UTC
on line 19 what are you trying to add fee to? and beginning balance isn't initialized when you check if it is less than 400. it should be
1 2 3 4
cout << "Enter beginning balance: " ;
cin >> beginning_balance;
if (beginning_balance < 400)
servicefee + fee;
also, it's good practice to initialize variables when declared, even just to zero.
Feb 5, 2014 at 12:47am UTC
I'm trying to add the fee(15$) to the total service fee at the end if the (beginning_balance < 400)
Feb 5, 2014 at 1:06am UTC
so, I would recommend doing this to the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float beginning_balance = 0.0, servicefee = 0.0, checkfees = 0.0;
float permonth = 10;
int checks_processed = 0;
int fee = 15;
cout << "Enter beginning balance: "
cin >> beginning_balance;
cout << "Enter number of checks processed: " ;
cin >> checks_processed;
if ( checks_processed < 20)
{
checkfees = .10 * checks_processed;
}
else // i removed the condition becuase it would result in no checkfee if checksprocessed equaled 20
{
checkfees = .08 * checks_processed;
}
servicefee = ( permonth + checkfees);
if ( beginning_balance < 400)
servicefee+=fee;
cout << "\nThe service fee for the month is $ " << servicefee;
return 0; }
Feb 5, 2014 at 1:24am UTC
Thank you for your help, it really helped me understand what to do and how to do it. Much appreciated.
Topic archived. No new replies allowed.