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

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
#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;
}

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
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;

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
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.