can someone help me out w a line of 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
34
35
36
37
38
39
40
#include <cstdlib>
#include <iostream>
#include <cmath>


 double A; //Amount;
double R; // Rate;
double T; //Time;
double Total;




using namespace std;

int main(int argc, char *argv[])
{
   
    
   
//1. Ask the user for the original amount of money, the interest rate and the time.

     cout << "What was the origional amount of money in the bank?" << endl;
     cin >> A;
     cout << "What is your current interest rate?" << endl;
     cin >> R;
     cout << "What is the rate of years?" << endl;
     cin >> T;
      
     
//2. Calculate the amount of money you will have if the original amount of money, P, is earning interest at r% for t years (compounded annually), the amount of money, A, will be: 
//A = P(1 + r/100)^t ... in other words >> Total = Amount(1 + Rate/100)^Time

Total = A*(1 + R/100)^T
    

//3. The output should look like this: 
//After ____ years at interest rate ____%, $____ will become $_______.  
    
        cout << "After  T  years at interest rate  R  %, $  A   will become $  Total  ."  endl;


^^^^^^^^^^^this line is giving me probems ^^^^^^^^^^^^^^^^
1
2
3
4
5
6
7
8
9
  
  //    cout << "After" << T << "years at interest rate" << R << "%, $" << A << " will become $" << Total << "." << endl;
      
    
    
   system("PAUSE");
    return EXIT_SUCCESS;
}

now im obviously doing something wrong here...
Last edited on
cout << "After T years at interest rate R %, $ A will become $ Total ." endl;

should be:
cout << "After T years at interest rate R %, $ A will become $ Total ." << endl;
Please use code tags.

You forgot to add << before endl;.
cout << "After T years at interest rate R %, $ A will become $ Total ." << endl;
dev c++ is giving me errors saying
1
2
47 C:*************** invalid operands of types `double' and `double' to binary `operator^' 
47 C:*************** expected `;' before "cout" 
Last edited on
It would be easier to read your first post, if you would include code tags...
(Please edit your first post, and include code tags.)
Last edited on
Yeah, i wan't sure about that, but i think those doubles need to be int's to work with the ^ operator.
edited
^ does not mean exponentation in C++. It means something else.

You need to use the pow() function:

1
2
x^y;  // <-bad
pow(x,y);  // <- good 


Also...

1
2
3
double A; //Amount;
double R; // Rate;
double T; //Time; 


If you have to comment explaining what the variable names mean... why don't you just give them descriptive names? Why not just name them Amount, Rate, Time instead of A, R, T?
Topic archived. No new replies allowed.