HELPPP PLEASE! Quick!

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;

//Inputs

std::cout << "Enter Principal Amount" << endl;
std::cin >> Interest rate



//Calculations/ Processing

TotalAmount = principal*(1+rate/t)^t;


//Output

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;









return 0;
}



What am I doing wrong. What else do I have to do.
Last edited on
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
yea i know it's a mess. I'm new to this stuff.
do you know how i would write the formula TotalAmount = principal*(1+rate/t)^t in this program
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
if i wanted to declare "t" would i write int t=time?
"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
ok gotcha
If you want I can write the program for you and show you then you can ask me why I did something a certain way or how somthing works?
that would be great. thank you
Ok well here is what I can put together... but your guidlines are a little miscommunicated and I am not sure how it is suppose to be.

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
#include <iostream>
using namespace std;

int main()
{
	double principal, rate, rrate, amount;
	int t;

	cout << "Principal : ";
	cin >> principal;
	cout << "Interest rate : ";
	cin >> rate;
	rrate = rate / 10.0;
	cout << "Times compounded : ";
	cin >> t;

	amount = principal * (1 + rrate / t) * t;

	system("cls");
	cout << "Interest Rate : %" << rate << endl << endl;
	cout << "Times Compounded : " << t << endl << endl;
	cout << "Principal : $" << principal << endl << endl;
	cout << "Amount : $" << amount;

	system("pause>nul");
}
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.
so if i run this program and enter the numbers above in my program specification, will the same amount in savings show up?
No... and that is because the formula you gave me is wrong
how is the formula wrong, im using the formula above in the assignment
Amount = Principal * (1 + Rate / T) T
Well it is wrong... obviously
so there's no way to use that formula to get those numbers?
i appreciate your help. Will you be able to help me with c++ programs in the future?
No problem... and of course!
Topic archived. No new replies allowed.