//Samuel LaManna
//Program 1 (intrest rate)
/*Variables:
Principal=P
Interest Rate=R
Times Compounded=T
Answer=A */
#include <iostream> //Input/output
using namespace std;
int main ()
{
int P, R, T, A; //Declaring Variables
cout<<endl;
cout<<"Interest Earned Calculator"; //Prints program title
cout<<endl;
cout<<endl;
cout<<"Please enter the Principal Value: ";
cin >> P;
cout<<endl;
cout<<endl;
cout<<"Please enter the Interest Rate (in decimal form): ";
cin >> R;
cout<<endl;
cout<<endl;
cout<<"Please enter the Number of times the interest is compounded in a year: ";
cin >> T;
cout<<endl;
cout<<endl;
A=P*((1+R)/T)^T;
cout<<"Interest Rate", cout<<R;
return 0;
}
When it gets to were it does the equation and starts outputting it gets all messed and thrown together. Its a simple interest calculator app.
I’ll guarantee that, if you’re doing interest rate calculations (or anything else requiring floating point accuracy), you should not be using an
intdata type.In addition
^is not the power operator, it’s the exclusive-or operator. You need to look into thepowstandard library function.That should hopefully be enough for you to figure out why your homework is misbehaving, without me doing all the work for you.
And you probably want to output
A(the answer) at some point 🙂