| admccann (11) | |
|
Trying to write a program to calculate interest due. If the persons balance is below £1000 the interest is 2% if its over £1000 the interest is 5%. Need the program to output the interest paid and the account balance with the interest added. I have done this so far but kinda stuck on how to get it to work out 2% of the balance. #include <iostream> using namespace std; int main() int sum int pct1 int pct2 { int balance; pct1 = "" cout << "What is your account balance?\nBalance: "; cin >> balance; cout << endl; } { if (balance <1000 ) return 0; } | |
|
Last edited on
|
|
| Felicia123 (158) | |||
|
u can try like this amac. and remember use code tag
it should be work and i didn't not check on compiler. try think with your concept if u want to addon smth | |||
|
Last edited on
|
|||
| admccann (11) | |
|
Not working for some reason its saying "error: expected initializer before ')' token" No idea what this means. #include <iostream> using namespace std; int main)_{ int accBalance = 0;//change keypoint name , initialize value are important float interestPaid = 0; float interestRate = 0; float totalBalance = 0; cout << "Enter account balance :£ "; cin >> accBalance; if( accBalance <= 1000 || accBalance > 0 ){ interestRate = 0.02; interestPaid = interestRate * accBalance; totalBalance = accBalance + interestPaid ; } else if( accBalance > 1000 ){ interestRate = 0.05; interestPaid = interestRate * accBalance; totalBalance = accBalance + interestPaid ; } cout << "Total Balance :£ " << totalBalance << endl; cout <<"Interest Rate : "; if( interestRate = 0.02 ) cout << "2%" << endl; else cout << "5%" << endl; cout <<"Interest Paid : " << interestPaid << endl; system( "pause" ); return 0; | |
|
|
|
| Felicia123 (158) | |
|
see the edited thread . just typo error .. u should know those error , although you are beginner try download the ebook name C++ Programming - Program Design Including Data Structures (5th Edition) it's useful | |
|
|
|
| admccann (11) | |
| Okay thanks i got it working but when you enter over 1000 as your balance its only works out 2% and not 5% | |
|
|
|
| Felicia123 (158) | |
|
edited. just add a == inside the if interestRate == 0.02 sometime type error. try check your self . haha | |
|
|
|