HELP: investment program..

I have no idea what i'm doing....i am beyond confused...any help that could let me know what variables i need to create or re assign or something anything helps...i know i need a for loop and or a do while loop in there to get the program to work....but my brain doesnt get it....

this is what the program should do:
the user will enter an amount indicating how much is to be invested annually, an annual rate of return, and the amount of money the user wants to have at the end of their investment period...

for example: the user invests $1000 with an annual return rate of 15% and they want to know how long it would take them to get $10,000...at the beginning of the first year the account balance would be $1000 at the end of the year the balance would be $1150 (balance + the years profit)...at the beginning of year 2 the account would hold $2150 (balance + year's new investment).. as the years go by the balance increases eventually to the point where the balance equals or exceeds the requested investment total.

the program should prompt the use for the required info then print out a table with each row showing the year, the balance at the beginning of the year and the balance at the end of the year...at the end of the table there should be a summary indicating how many years were needs to achieve the goal, how much money was invested and how much return was accumulated on the investment and by how much the investment total exceeded the goal....

if someone could tell me how many additional variable i need to create this would be very helpful or just give me more information on what to do would be very helpful...we need to use functions as much as possible for this program..this is what i have so far...i know one of the equations somewhere needs to be endYearBalance = (annualInvestment * (returnRate/100)) + annualInvestment...but after that im so lost...

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include<iostream>
#include <iomanip>

using namespace std;

//*****************************************************
//                Function Prototypes
//*****************************************************
void intro();
char getChoice();
void doInvestment();
void doBorrowing();
void investmentInput(double&, double&, double&);
void borrowingInput(double&, double&, double&);
void investmentOutput();
void borrowingOutput();
void investmentSummary();
void borrowingSummary();

//*****************************************************
//                   Main Program
//*****************************************************

int main()
{
// Variables
char userChoice;
//Function calls
intro();
userChoice = getChoice();

//Closing remarks
system("pause");
return 0;
}

//*****************************************************
//                Function Definitons
//*****************************************************

void intro()
// Purpose:   show intro
// Parameters: none
// Returns:    None
{
cout << " Welcome to the Bank of Kwantlen...again...yay" << endl;
}

char getChoice()
// Purpose: gets users choice for investment or borrowing  
// Parameters: none
// Returns: userchoice
{
char userChoice;
cout << " Would you like to invest (i) or borrow (b) from us?";
cin >> userChoice;

if (userChoice == 'i' || userChoice == 'I')
doInvestment();	
else if (userChoice == 'b' || userChoice == 'B')
doBorrowing();

return userChoice;
}
void doInvestment()
// Purpose: directs user to function? 
// Parameters: none
// Returns:None
{
double annualInvestment;
double returnRate;
double endGoal;
investmentInput(annualInvestment, returnRate, endGoal);
}

void investmentInput(double& annualInvestment, double& returnRate, double& endGoal)
// Purpose: recieves input from user 
// Parameters: listed 
// Returns: none
{
int year = 1;

cout << " Enter the amount you want to invest annually: ";
cin >> annualInvestment;

cout << " Enter the yearly percentage rate of return: ";
cin >> returnRate;

cout << " Enter investment goal: ";
cin >> endGoal;	

cout << endl;
cout << "Year" << "     Balance (Jan. 1)" << "     Balance (Dec. 31)" << endl;

//this is where the table should show up..i think...or i could stick it 
//in a whole nother function and just call it from here....

}
You are WAY overthinking this and some of the functions you have are not needed or do much more that you want them to do and I think that is why you are getting confused. If you have any question just ask.

HERE IS MY REVISE CODE IT DOES SOMETHING SIMILAR TO WHAT YOU POST:
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include<iostream>

using namespace std;

///Function Prototypes
char getChoice(); // Purpose: gets users choice for investment or borrowing
void doInvestment(); //Purpose: Do investment algorithm.
void doBorrowing();//Purpose: Do Borrow algorithm.

///Main function
int main()
{
     //Vars
     char userInput; //Input of the user.


     //Intro
     cout << " Welcome to the Bank of Kwantlen...again...yay \n" << endl;
     userInput = getChoice(); //get the choice.
     //Do what the user want you to do.
    if (userInput == 'i' ||userInput == 'I')
    doInvestment();
    else if (userInput == 'b' || userInput == 'B')
    doBorrowing();


}

///Functions
//getChoice Function
char getChoice()
{
char userChoice;
cout << " Would you like to invest (i) or borrow (b) from us? ";
cin >> userChoice;

return userChoice;
}

//doInvestment Function
void doInvestment()
{

    int year = 1; //hold current year.
    double currBal, annualInvestment,  returnRate, endGoal;

    /*
      currBal - current balance of user.
      aannualInvestment - ammount the user will invest each year.
      returnRate - percentage of the annual investment user will also get.
      endGoal - ammount user wants to end up with.
    */


    cout << " Enter the amount you want to invest annually: ";
    cin >> annualInvestment;

    cout << " Enter the yearly percentage rate of return (Input as decimal):  ";
    cin >> returnRate;

    cout << " Enter investment goal:  ";
    cin >> endGoal;

    currBal = annualInvestment; //start off with the annual investment.

    //Main Loop
    while(currBal <= endGoal) //While we havent reach our goal ammount and it is not the first year.
    {

          cout << "Year : " << year << endl; //display the current year.
          cout << "Year's Beginning Balance : " << currBal << endl; //show the beginning year balance
          currBal = (currBal + annualInvestment) + (annualInvestment * returnRate); //do the investment algorithm to the current Balance.
          cout << "Year's Ending Balance : " << currBal << endl << endl << endl; //show year's ending balance.
         year++; //go to next year.
    }
    cout << "It took about " << year - 1 << " year(s) to get to " << endGoal << endl; //once we reach our goal, show how many years it took.
}

//doBorrowing Function
void doBorrowing()
{

}



OUTPUT

 Welcome to the Bank of Kwantlen...again...yay

 Would you like to invest (i) or borrow (b) from us? i
 Enter the amount you want to invest annually: 1000
 Enter the yearly percentage rate of return (Input as decimal):  .15
 Enter investment goal:  10000
Year : 1
Year's Beginning Balance : 1000
Year's Ending Balance : 2150


Year : 2
Year's Beginning Balance : 2150
Year's Ending Balance : 3300


Year : 3
Year's Beginning Balance : 3300
Year's Ending Balance : 4450


Year : 4
Year's Beginning Balance : 4450
Year's Ending Balance : 5600


Year : 5
Year's Beginning Balance : 5600
Year's Ending Balance : 6750


Year : 6
Year's Beginning Balance : 6750
Year's Ending Balance : 7900


Year : 7
Year's Beginning Balance : 7900
Year's Ending Balance : 9050


Year : 8
Year's Beginning Balance : 9050
Year's Ending Balance : 10200


It took about 8 year(s) to get to 10000

Process returned 0 (0x0)   execution time : 11.755 s
Press any key to continue.
Thank you so so sooooo much!!! this clarified things a lot for me, i was able to extract bits and pieces of the code you provided and make it apply to my specific assignment. i changed my code to look as follows (keeping the frivolous functions only because its a requirement of the assignment)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include<iostream>
#include <iomanip>

using namespace std;

//*****************************************************
//                Function Prototypes
//*****************************************************
	char getChoice();
	char repeatProgram();
	void intro();
	void doInvestment();
	void doBorrowing();
	void investmentInput(double&, double&, double&);
	void borrowingInput(double&, double&, double&);
	void investmentOutput(double&, double&, double&);
	void borrowingOutput(double&, double&, double&);
	void investmentSummary(int&, double&, double&, double&);
	void borrowingSummary(int&, double&, double&, double&);	
	
//*****************************************************
//                   Main Program
//*****************************************************

int main()
{
// Variables
	char userInput;

//Function calls
	intro();
	userInput = getChoice();

//Closing remarks
	system("pause");
	return 0;
}

//*****************************************************
//                Function Definitons
//*****************************************************

void intro()
{
	cout << " Welcome to the Bank of Kwantlen...again...yay" << endl;
}

char getChoice()
{
	char repeat;
	char userInput;
	cout << " Would you like to invest (i) or borrow (b) from us?";
	cin >> userInput;
	if (userInput == 'i' || userInput == 'I')
	doInvestment();	
	else if (userInput == 'b' || userInput == 'B')
	doBorrowing();
	
	return userInput;
}
		
void doInvestment()
{
	double annualInvestment;
	double returnRate;
	double endGoal;
	double endBalance;
	int year;
	investmentInput(annualInvestment, returnRate, endGoal);
	investmentOutput(annualInvestment, returnRate, endGoal);
	
}
void investmentInput(double& annualInvestment, double& returnRate, double& endGoal)
{
	cout << endl;

	cout << " Enter the amount you want to invest annually: ";
	cin >> annualInvestment;

	cout << " Enter the yearly percentage rate of return (input as decimal): ";
	cin >> returnRate;

	cout << " Enter investment goal: ";
	cin >> endGoal;	
}

void investmentOutput(double& annualInvestment, double& returnRate, double& endGoal)
{
	int year = 1;
	double endBalance;
	endBalance = (annualInvestment * returnRate) + annualInvestment;
	double newBalance;
	cout << "Year" << "     Balance (Jan. 1)" << "    Balance (Dec. 31)" << endl;
	cout << year << "        " << fixed << setprecision(2) << annualInvestment << "             " << fixed << setprecision(2) << endBalance << endl;
	while (endBalance <= endGoal)
	{
	newBalance = endBalance + annualInvestment;
	endBalance = (newBalance * returnRate) + newBalance;
	cout << year + 1 << "        " << newBalance << "             " << endBalance << endl;
	year ++;
	}
	investmentSummary(year, endBalance, endGoal, annualInvestment);
}

void investmentSummary(int& year, double& endBalance, double& endGoal, double& annualInvestment)
{
	double extraBalance;
	double totalInvestment;
	double totalReturn;
	totalInvestment = annualInvestment * year;
	totalReturn = endBalance - totalInvestment;
	extraBalance = endBalance - endGoal;
	cout << endl;
	cout << "Number of years needed to achieve investment goal: " << year << endl;
	cout << "Total investment:                                  " << totalInvestment << endl;
	cout << "Total accumulated return on investment:            " << totalReturn << endl;
	cout << "Final balance exceeds goal by:                     " << extraBalance << endl;
	repeatProgram();
}

void doBorrowing()
{
	double loanAmount;
	double annualIntRate;
	double annualPayment;
	borrowingInput(loanAmount, annualIntRate, annualPayment);
	borrowingOutput(loanAmount, annualIntRate, annualPayment);
}

void borrowingInput(double& loanAmount, double& annualIntRate, double& annualPayment)
{
	cout << endl;

	cout << "Enter the amount of the loan: ";
	cin >> loanAmount;

	cout << "Enter the annual interest rate (input as decimal): ";
	cin >> annualIntRate;

	cout << "Enter the annual payment amount: ";
	cin >> annualPayment;
}

void borrowingOutput(double& loanAmount, double& annualIntRate, double& annualPayment)
{
	int year = 1;
	double endBalance;
	endBalance = ((loanAmount * annualIntRate) + loanAmount) - annualPayment;
	double newBalance;
	cout << "Year" << "     Balance (Jan. 1)" << "    Balance (Dec. 31)" << endl;
	cout << year << "        " <<fixed << setprecision(2) << loanAmount << "             " << fixed << setprecision(2) << endBalance << endl;
	while (endBalance > 0)
	{
	newBalance = endBalance;
	endBalance = ((newBalance * annualIntRate) + newBalance) - annualPayment;
	cout << year + 1 << "        " << newBalance << "             " << endBalance << endl;
	year ++;
	}
	borrowingSummary(year, loanAmount, annualPayment, endBalance);
}

void borrowingSummary(int& year, double& loanAmount, double& annualPayment, double& endBalance)
{
	double totalPayments;
	double totalInterestCharged;
	totalPayments = (year * annualPayment);
	totalInterestCharged = (totalPayments + endBalance) - loanAmount;
	cout << endl;
	cout << "Number of years needs to pay back loan: " << year << endl;
	cout << "Total of payments:                      " << totalPayments << endl;
	cout << "Total of interest charged:              " << totalInterestCharged << endl;
	cout << "Balance at end of period:               " << endBalance << endl;
	repeatProgram();
}

char repeatProgram()
{
	char repeat;
	cout << "Would you like to make another investment/loan calculation? (y/n) ";
	cin >> repeat;

	return repeat;
}


OUTPUT (for an investment)

Welcome to the Bank of Kwantlen...again...yay
Would you like to invest(i) or borrow (b) from us? i

Enter the amount you want to invest annually: 1000
Enter the yearly percentage rate of return (input as decimal): 0.15
Enter investment goal: 10000
Year     Balance (Jan.1)      Balance (Dec.31)
1          1000.00                 1150.00
2          2150.00                 2472.50
3          3472.50                 3993.38
4          4993.38                 5742.38
5          6742.38                 7753.74 
6          8753.74                 10066.80

Number of years needed to achieve investment goal: 6
Total investment: 6000.00
Total accumulated return on  investment: 4066.80
Final balance exceeds goal by: 66.80
Would you like to make another investment/loan calculation? (y/n)


The repeat is where i'm stuck. Where should i input my do..while loop to make the entire program start again? It should start back up at "would you like to invest or borrow with us?" Any help is greatly appreciated =) i'm ALMOST DONE this assignment!!
I figured it out. In my main program i added in the do while loop as such:
1
2
3
4
5
6
7
8
char repeat;
char unerInput;
intro();	
do
{
userInput = getChoice();
repeat = repeatProgram();
}while (repeat == 'y');


and took out the function call repeatProgram(); from within the borrowingSummary and investingSummary functions or else the question repeats twice before starting over. =)
Good job, Im glad I can help.
Topic archived. No new replies allowed.