I need help please!

I'm stuck and dont know how to turn FV = P ((r+1)^N-1)(r+1)/r into c++ code.
where, r = R/5200, the decimal equivalent of the weekly interest rate.

"Write a program that computes the future value of a "Holiday Club" account.

The idea is that every week, on Friday, a person deposits P dollars into a special savings account. The weekly deposit is always the same: P dollars. Before the first deposit is made, there is no money in the account. Whatever money is in the account earns interest at some particular fixed rate, compounded weekly. As the weeks go by, there is more and more money in the account, and so every week the amount of additional interest is larger and larger. Eventually the time arrives for purchasing holiday gifts. One Friday, instead of depositing another payment, the owner of the account withdraws all the money and spends it. "

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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
 
#include <iostream>
#include <cmath>

using namespace std ;


/* PROTOTYPES */

void   PrintDirections() ;
/* Exactly what this function must do:
 Print directions for the user of the program. */

double GetPmt() ;
/* Exactly what this function must do:
 Prompt the user to enter the amount
 of the weekly payment, read it in,
 and return it to the caller. */

double GetRate() ;
/* Exactly what this function must do:
 Prompt the user to enter the amount
 of the annual interest rate, read it in,
 and return it to the caller. */

int GetNumWeeks() ;
/* Exactly what this function must do:
 Prompt the user to enter the number
 of weekly payments, read it in,
 and return it to the caller. */

double Compute_FV(double P, double R, int N)  ;
/* Exactly what this function must do:
 Return the future value of N payments
 of P dollars at annual interest rate
 percentage R. */

void Report_FV(double P, double R, int N, double fv) ;
/* Exactly what this function must do:
 Report to the user -- tell the user
 that fv is the future value of N payments
 of P dollars at annual interest rate
 percentage R. */

/* **************************************** */
/*                 MAIN                     */
/* **************************************** */

int main ()
{
    double pmt, rate ;
    int weeks;
    
    PrintDirections();
    
     pmt = GetPmt() ;
    
    rate = GetRate() ;
    
    weeks = GetNumWeeks() ;
 
    
}



/* **************************************** */
/*               PRINT DIRECTIONS           */
/* **************************************** */

/* Exactly what this function must do:
 Print directions for the user of the program. */

void PrintDirections()
{
    
    cout << endl ;
    cout << "This program will calculate the futrue calue of N\n" ;
    cout << "weekly payments of P dollars at annual interest\n" ;
    cout << "rate R." << endl ;
    cout << endl ;
    cout << "You will be prompted to enter P, R, and N (in that\n" ;
    cout << "order) and then the future value will be\n" ;
    cout << "calculated and written to the screen." << endl ;
    cout << endl ;
    
}



/* **************************************** */
/*                    GETPMT                */
/* **************************************** */

/* Exactly what this function must do:
 Prompt the user to enter the amount
 of the weekly payment, read it in,
 and return it to the caller. */

double GetPmt()
{
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    
    double pmt ;

    cout << endl ;
    cout << "You must now enter the amount of the payment P in\n" ;
    cout << "decimal form (for example: 54.55).  Do *not*\n" ;
    cout << "include a dollar sign ($).  Do *not* include any\n" ;
    cout << "commas." << endl ;
    cout << endl ;
    cout << "Enter P, the amount of each weekly payment here ==> P = " ;
    cin >> pmt ;
    
    return pmt ;

}



/* **************************************** */
/*                    GETRATE               */
/* **************************************** */

/* Exactly what this function must do:
 Prompt the user to enter the amount
 of the annual interest rate, read it in,
 and return it to the caller. */

double GetRate()
{
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(3);
    
    double rate ;
    
    cout << endl ;
    cout << "Now you must enter the annual interest rate in\n" ;
    cout << "decimal form (for example: 8.125).  Do *not*\n" ;
    cout << "include a percent sign (%).  Do *not* include any\n" ;
    cout << "commas." <<endl ;
    cout << endl ;
    cout << "Enter R, the annual interest rate here ==> R = " ;
    cout << endl ;
    cin >> rate ;
    
    return rate ;
}



/* **************************************** */
/*              GETNUMWEEKS                 */
/* **************************************** */

/* Exactly what this function must do:
 Prompt the user to enter the number
 of weekly payments, read it in,
 and return it to the caller. */

int GetNumWeeks()
{
    int weeks ;
    
    cout << endl ;
    cout << "Now you must enter the number of weekly payments\n" ;
    cout << "as a whole positive integer (for example: 45).  Do *not*\n" ;
    cout << "include a decimal point or any commas.\n" ;
    cout << endl ;
    cout << "Enter N, the number of weekly payments, here ==> N = " ;
    cout << endl ;
    cin >> weeks ;
    
    return weeks ;

}



/* **************************************** */
/*              COMPUTE_FV                  */
/* **************************************** */

/* Exactly what this function must do:
 Return the future value of N payments
 of P dollars at annual interest rate
 percentage R. */

double Compute_FV(double P, double R, int N)
{
    double r (r=R/5200) ;
    
}



/* **************************************** */
/*              REPORT_FV                   */
/* **************************************** */

/* Exactly what this function must do:
 Report to the user -- tell the user
 that fv is the future value of N payments
 of P dollars at annual interest rate
 percentage R. */

void Report_FV(double P, double R, int N, double fv)
{
    
    cout << endl ;
    cout << "Here is your answer\n" ;
    cout << endl ;
    cout << "The future value of "<<N<<" weekly payements of\n" ;
    cout << "$"<<P<<" at "<<R<<" is "<<fv<<" \n" ;
    cout << endl ;
}



/* **************************************** */
/*                   END                    */
/* **************************************** */
Last edited on
I'm stuck and dont know how to turn FV = P ((r+1)^N-1)(r+1)/r into c++ code.
I can't tell if the -1 is part of the exponent, so:
FV = P * pow(r + 1, N - 1) * (r + 1) / r;
if it is, or
FV = P * (pow(r + 1, N) - 1) * (r + 1) / r;
if it isn't.
Thank helios that helped me !

Also im stuck on how to declare the future value (FV) and where to put it so that it outputs the write answer?

Can you help me on what is suppose to go here?
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
/* **************************************** */
/*              COMPUTE_FV                  */
/* **************************************** */

/* Exactly what this function must do:
 Return the future value of N payments
 of P dollars at annual interest rate
 percentage R. */

double Compute_FV(double P, double R, int N)
{
    
}



/* **************************************** */
/*              REPORT_FV                   */
/* **************************************** */

/* Exactly what this function must do:
 Report to the user -- tell the user
 that fv is the future value of N payments
 of P dollars at annual interest rate
 percentage R. */

void Report_FV(double P, double R, int N, double fv)
{
}
Last edited on
1
2
double FV = /*expression*/;
return FV;
inside Compute_FV(). Or just return the expression.
Topic archived. No new replies allowed.