Nov 18, 2015 at 11:54pm UTC  
 
#include <iostream> 
#include <iomanip> 
using namespace std; 
 
int main() 
{ 
	double balance; 
	double deposit; 
	double withdrawl; 
	double interest; 
	double gainedInt; 
	double monthlyInt; 
	int num = 1; 
	double intBalance; 
 
	cout << "Please enter the initial balace: "; 
	cin >> balance; 
 
	intBalance = balance; 
 
	cout << "Please enter the annual interest rate: "; 
	cin >> interest; 
 
	monthlyInt = interest / 12; 
 
 
	while (num < 4) 
	{ 
		cout << " Month " << num << endl; 
		cout << " Total Balance: " << balance << endl; 
		cout << " Enter the total deposited: " << endl; 
		cin >> deposit; 
		balance = balance + deposit; 
		cout << " Enter the total withdrawn: " << endl; 
		cin >> withdrawl; 
		balance = balance - withdrawl; 
		gainedInt = balance*monthlyInt; 
		balance = balance + gainedInt; 
		num = num + 1; 
	} 
 
 
	cout << " Starting Balance: " << intBalance << endl; 
	cout << " Annual interest rate (%): " << interest << endl; 
	cout << "Month 1 Deposit " << deposit << " , Withdrawal " << withdrawl << endl; 
	cout << "Month 2 Deposit " << deposit << " , Withdrawal " << withdrawl << endl; 
	cout << "Month 3 Deposit " << deposit << " , Withdrawal " << withdrawl << endl; 
 
	return 0; 
} 
 
this is my code so far, I need help getting the deposit values from the loop, and into the last part of my code, I know that I am using the same int for the last part, I just don't know how to individually change it.
 
 
 
 
  Nov 19, 2015 at 5:08am UTC  
 
Thanks for the replies and sorry for the code tag error, this is my first post, I read the article and I'm still not sure how to use the array in my code, further assistance would help a lot if possible, thanks for your time so far @Kevin C
 
 
 
 
  Nov 19, 2015 at 10:28am UTC  
 
#include<vector> 
 
... 
 
int main() 
{ 
double balance; 
vector<double> deposit(4); 
 
... 
 
cin >> deposit[num]; 
balance = balance + deposit[num]; 
... 
 
cout << "Month 1 Deposit " << deposit[1] << ...
Last edited on Nov 19, 2015 at 10:30am UTC