This is my project:
Assuming there are no deposits other than the original investment, the balance in a savings account after one year may be calculated as:
Amount = Principal * (1 + Rate / T) T
Principal is the balance in the savings account initially, Rate is the interest rate and T is the number of times the interest is compounded during a year (T is 4 if the interest is compounded quarterly).
You are going to write a program that asks the user for the principal, the interest rate and the number of times the interest is compounded. It should display a report similar to
Interest Rate: 4.25%
Times Compounded: 12
Principal: $ 1000.00
Interest: $ 43.34
Amount in Savings: $ 1043.34
When you run the program to hand in, use the following values (you will run it two times, which means you will do ./a.out two times; you only have to do the cat and g++ one time in the script):
Run 1 Run 2
Principal 548.32 6763.00
Interest rate 4.25% 2.5%
Times compounded 12 4
This is my code so far:
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, const char * argv[])
{
//Declarations
double rate; //Interest Rate 1 year
double time; // Number of time compounded
double principal; //Total amount before Interest Rate
double newbalance; //Total amount after Interest Rate
double amount of interest;
std::cout << "The rate of return is" << rate << endl;
std::cout << "The current balance is" << principal << endl;
std::cout << "Interest will be accured" << period << 'time per year << endl;
Your code is a mess....
1)You are using namespace std so dont't write std::cout or std::cin
2)A variable cannot have spaces in it (double amount of interest)
3)Why are you passing arguments to main? No need
4)(cin >> Interest rate) there is no "Interest rate" variable and even if there was it cannot have a space
5)OMG your program is a mess.... sorry
well in c++ that would be fine except for the ^t part... but if you #include <cmath>
you can use the function pow(num, what power to be raised to) to raise a number to a power..so
TotalAmount = principal * pow((1+rate/t), t);
I believe
Not sure tho.... anyways if you need anything else let me know
"time" is not an integer so no that would be incorrect
you can only use integer values for an int variable
"time" is a string
10 is an int
10.3 is a float or double
't' is a char
Also I just looked at the top and it says Amount = Principal * (1 + Rate / T) T
So disregard what I said about raising to the power
it would just be
amount = principal *(1+rate/t)*t
That is.. unless the order of operations is supposed to be calculated a certain way
I like the way it looks, would you mind labeling the different sections such as
//Declarations
//Inputs
//Calculations/Processing
//Outputs
I'm kind of confused the way you have it.
My teacher wants us to be able to enter the number he has in the specifications to get a specific number for the amount in savings. Thats why he has run 1 and run 2
Look buddy I gave you a great starting point, now I am glad to help out but I am not going to do the whole thing for you... sorry. In plus this is your "homework" which you are suppose to learn from.