### Interest rates.

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
u can try like this amac.
and remember use code tag

 ``12345678910111213141516171819202122232425262728293031323334`` ``````#include 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; }``````

it should be work and i didn't not check on compiler.
Last edited on
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;

just typo error ..
u should know those error , although you are beginner

it's useful
Okay thanks i got it working but when you enter over 1000 as your balance its only works out 2% and not 5%
edited.

just add a == inside the if

interestRate == 0.02

sometime type error.
try check your self . haha
Topic archived. No new replies allowed.